[PATCH 1/1] Adjust DList names to make sense.
"Matthew W. S. Bell" <[email protected]> Sun, 15 Nov 2009 04:24:28 +0000
| Newsgroups | gmane.comp.gnome.evolution.patches |
|---|---|
| Message-ID | <[email protected]> |
--===============0423164086== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-CLQswaxdZNCRM6arpvSR" --=-CLQswaxdZNCRM6arpvSR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I recently spent a fun afternoon trying to work out why dlist->tail didn't do what I expected it to (I'm not very bright). After working out that tailpred (tail predecessor) was what I wanted and that tail was never used, I couldn't see any reason for the fields to be named according to their use. So here it is. Matthew W.S. Bell From: Matthew W. S. Bell <[email protected]> --- camel/camel-block-file.c | 2 +- camel/camel-iconv.c | 22 +++++++++++----------- camel/camel-list-utils.c | 20 ++++++++++---------- camel/camel-list-utils.h | 8 ++++---- camel/camel-text-index.c | 2 +- libedataserver/e-iconv.c | 22 +++++++++++----------- libedataserver/e-msgport.c | 22 +++++++++++----------- libedataserver/e-msgport.h | 4 ++-- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/camel/camel-block-file.c b/camel/camel-block-file.c index 673ff80..06d1361 100644 --- a/camel/camel-block-file.c +++ b/camel/camel-block-file.c @@ -574,7 +574,7 @@ CamelBlock *camel_block_file_get_block(CamelBlockFile *= bs, camel_block_t id) g_hash_table_insert(bs->blocks, GUINT_TO_POINTER(bl->id), bl); =20 /* flush old blocks */ - flush =3D (CamelBlock *)bs->block_cache.tailpred; + flush =3D (CamelBlock *)bs->block_cache.tail; prev =3D flush->prev; while (bs->block_cache_count > bs->block_cache_limit && prev) { if (flush->refcount =3D=3D 0) { diff --git a/camel/camel-iconv.c b/camel/camel-iconv.c index 2533d1f..78c87a6 100644 --- a/camel/camel-iconv.c +++ b/camel/camel-iconv.c @@ -60,11 +60,11 @@ typedef struct _CamelDListNode { =20 typedef struct _CamelDList { struct _CamelDListNode *head; + struct _CamelDListNode *terminator; struct _CamelDListNode *tail; - struct _CamelDListNode *tailpred; } CamelDList; =20 -#define CAMEL_DLIST_INITIALISER(l) { (CamelDListNode *)&l.tail, 0, (CamelD= ListNode *)&l.head } +#define CAMEL_DLIST_INITIALISER(l) { (CamelDListNode *)&l.terminator, 0, (= CamelDListNode *)&l.head } =20 struct _iconv_cache_node { struct _iconv_cache_node *next; @@ -160,9 +160,9 @@ struct { and g_list's are f@@#$ed up to make this a hassle */ static void camel_dlist_init(CamelDList *v) { - v->head =3D (CamelDListNode *)&v->tail; - v->tail =3D NULL; - v->tailpred =3D (CamelDListNode *)&v->head; + v->head =3D (CamelDListNode *)&v->terminator; + v->terminator =3D NULL; + v->tail =3D (CamelDListNode *)&v->head; } =20 static CamelDListNode *camel_dlist_addhead(CamelDList *l, CamelDListNode *= n) @@ -176,10 +176,10 @@ static CamelDListNode *camel_dlist_addhead(CamelDList= *l, CamelDListNode *n) =20 static CamelDListNode *camel_dlist_addtail(CamelDList *l, CamelDListNode *= n) { - n->next =3D (CamelDListNode *)&l->tail; - n->prev =3D l->tailpred; - l->tailpred->next =3D n; - l->tailpred =3D n; + n->next =3D (CamelDListNode *)&l->terminator; + n->prev =3D l->tail; + l->tail->next =3D n; + l->tail =3D n; return n; } =20 @@ -467,7 +467,7 @@ camel_iconv_open (const gchar *oto, const gchar *ofrom) if (ic) { camel_dlist_remove((CamelDListNode *)ic); } else { - struct _iconv_cache *last =3D (struct _iconv_cache *)iconv_cache_list.ta= ilpred; + struct _iconv_cache *last =3D (struct _iconv_cache *)iconv_cache_list.ta= il; struct _iconv_cache *prev; =20 prev =3D last->prev; @@ -496,7 +496,7 @@ camel_iconv_open (const gchar *oto, const gchar *ofrom) camel_dlist_addhead(&iconv_cache_list, (CamelDListNode *)ic); =20 /* If we have a free iconv, use it */ - in =3D (struct _iconv_cache_node *)ic->open.tailpred; + in =3D (struct _iconv_cache_node *)ic->open.tail; if (in->prev && !in->busy) { cd(printf("using existing iconv converter '%s'\n", ic->conv)); ip =3D in->ip; diff --git a/camel/camel-list-utils.c b/camel/camel-list-utils.c index bf9489b..2e9b7e5 100644 --- a/camel/camel-list-utils.c +++ b/camel/camel-list-utils.c @@ -38,9 +38,9 @@ void camel_dlist_init (CamelDList *v) { - v->head =3D (CamelDListNode *)&v->tail; - v->tail =3D NULL; - v->tailpred =3D (CamelDListNode *)&v->head; + v->head =3D (CamelDListNode *)&v->terminator; + v->terminator =3D NULL; + v->tail =3D (CamelDListNode *)&v->head; } =20 /** @@ -74,10 +74,10 @@ camel_dlist_addhead (CamelDList *l, CamelDListNode *n) CamelDListNode * camel_dlist_addtail (CamelDList *l, CamelDListNode *n) { - n->next =3D (CamelDListNode *)&l->tail; - n->prev =3D l->tailpred; - l->tailpred->next =3D n; - l->tailpred =3D n; + n->next =3D (CamelDListNode *)&l->terminator; + n->prev =3D l->tail; + l->tail->next =3D n; + l->tail =3D n; return n; } =20 @@ -135,11 +135,11 @@ camel_dlist_remtail (CamelDList *l) { CamelDListNode *n, *np; =20 - n =3D l->tailpred; + n =3D l->tail; np =3D n->prev; if (np) { np->next =3D n->next; - l->tailpred =3D np; + l->tail =3D np; return n; } return NULL; @@ -156,7 +156,7 @@ camel_dlist_remtail (CamelDList *l) gint camel_dlist_empty (CamelDList *l) { - return (l->head =3D=3D (CamelDListNode *)&l->tail); + return (l->head =3D=3D (CamelDListNode *)&l->terminator); } =20 /** diff --git a/camel/camel-list-utils.h b/camel/camel-list-utils.h index e75ef23..e5cb5f0 100644 --- a/camel/camel-list-utils.h +++ b/camel/camel-list-utils.h @@ -55,8 +55,8 @@ struct _CamelDListNode { * struct _CamelDList - A double-linked list header. * * @head: The head node's next pointer. - * @tail: The tail node's next pointer. - * @tailpred: The previous node to the tail node. + * @terminator: The head's prev and tail's next pointer. + * @tail: The tail node's prev pointer. * * This is the merging of two separate head and tail nodes into a * single structure. i.e. if you ahve a NULL terminated head and tail @@ -68,11 +68,11 @@ struct _CamelDListNode { **/ struct _CamelDList { struct _CamelDListNode *head; + struct _CamelDListNode *terminator; struct _CamelDListNode *tail; - struct _CamelDListNode *tailpred; }; =20 -#define CAMEL_DLIST_INITIALISER(l) { (CamelDListNode *)&l.tail, 0, (CamelD= ListNode *)&l.head } +#define CAMEL_DLIST_INITIALISER(l) { (CamelDListNode *)&l.terminator, 0, (= CamelDListNode *)&l.head } =20 void camel_dlist_init(CamelDList *v); CamelDListNode *camel_dlist_addhead(CamelDList *l, CamelDListNode *n); diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c index f696fd7..e6453b3 100644 --- a/camel/camel-text-index.c +++ b/camel/camel-text-index.c @@ -214,7 +214,7 @@ text_index_add_name_to_word(CamelIndex *idx, const gcha= r *word, camel_key_t name g_hash_table_insert(p->words, w->word, w); camel_dlist_addhead(&p->word_cache, (CamelDListNode *)w); p->word_cache_count++; - ww =3D (struct _CamelTextIndexWord *)p->word_cache.tailpred; + ww =3D (struct _CamelTextIndexWord *)p->word_cache.tail; wp =3D ww->prev; while (wp && p->word_cache_count > p->word_cache_limit) { io(printf("writing key file entry '%s' [%x]\n", ww->word, ww->data)); diff --git a/libedataserver/e-iconv.c b/libedataserver/e-iconv.c index 411f71c..61f5bd4 100644 --- a/libedataserver/e-iconv.c +++ b/libedataserver/e-iconv.c @@ -60,11 +60,11 @@ typedef struct _EDListNode { =20 typedef struct _EDList { struct _EDListNode *head; + struct _EDListNode *terminator; struct _EDListNode *tail; - struct _EDListNode *tailpred; } EDList; =20 -#define E_DLIST_INITIALISER(l) { (EDListNode *)&l.tail, 0, (EDListNode *)&= l.head } +#define E_DLIST_INITIALISER(l) { (EDListNode *)&l.terminator, 0, (EDListNo= de *)&l.head } =20 struct _iconv_cache_node { struct _iconv_cache_node *next; @@ -157,9 +157,9 @@ static const struct { and g_list's are f@@#$ed up to make this a hassle */ static void e_dlist_init(EDList *v) { - v->head =3D (EDListNode *)&v->tail; - v->tail =3D NULL; - v->tailpred =3D (EDListNode *)&v->head; + v->head =3D (EDListNode *)&v->terminator; + v->terminator =3D NULL; + v->tail =3D (EDListNode *)&v->head; } =20 static EDListNode *e_dlist_addhead(EDList *l, EDListNode *n) @@ -173,10 +173,10 @@ static EDListNode *e_dlist_addhead(EDList *l, EDListN= ode *n) =20 static EDListNode *e_dlist_addtail(EDList *l, EDListNode *n) { - n->next =3D (EDListNode *)&l->tail; - n->prev =3D l->tailpred; - l->tailpred->next =3D n; - l->tailpred =3D n; + n->next =3D (EDListNode *)&l->terminator; + n->prev =3D l->tail; + l->tail->next =3D n; + l->tail =3D n; return n; } =20 @@ -462,7 +462,7 @@ iconv_t e_iconv_open(const gchar *oto, const gchar *ofr= om) if (ic) { e_dlist_remove((EDListNode *)ic); } else { - struct _iconv_cache *last =3D (struct _iconv_cache *)iconv_cache_list.ta= ilpred; + struct _iconv_cache *last =3D (struct _iconv_cache *)iconv_cache_list.ta= il; struct _iconv_cache *prev; =20 prev =3D last->prev; @@ -491,7 +491,7 @@ iconv_t e_iconv_open(const gchar *oto, const gchar *ofr= om) e_dlist_addhead(&iconv_cache_list, (EDListNode *)ic); =20 /* If we have a free iconv, use it */ - in =3D (struct _iconv_cache_node *)ic->open.tailpred; + in =3D (struct _iconv_cache_node *)ic->open.tail; if (in->prev && !in->busy) { cd(printf("using existing iconv converter '%s'\n", ic->conv)); ip =3D in->ip; diff --git a/libedataserver/e-msgport.c b/libedataserver/e-msgport.c index 7a2c6ee..861d686 100644 --- a/libedataserver/e-msgport.c +++ b/libedataserver/e-msgport.c @@ -198,9 +198,9 @@ out0: =20 void e_dlist_init(EDList *v) { - v->head =3D (EDListNode *)&v->tail; - v->tail =3D NULL; - v->tailpred =3D (EDListNode *)&v->head; + v->head =3D (EDListNode *)&v->terminator; + v->terminator =3D NULL; + v->tail =3D (EDListNode *)&v->head; } =20 EDListNode *e_dlist_addhead(EDList *l, EDListNode *n) @@ -214,10 +214,10 @@ EDListNode *e_dlist_addhead(EDList *l, EDListNode *n) =20 EDListNode *e_dlist_addtail(EDList *l, EDListNode *n) { - n->next =3D (EDListNode *)&l->tail; - n->prev =3D l->tailpred; - l->tailpred->next =3D n; - l->tailpred =3D n; + n->next =3D (EDListNode *)&l->terminator; + n->prev =3D l->tail; + l->tail->next =3D n; + l->tail =3D n; return n; } =20 @@ -246,11 +246,11 @@ EDListNode *e_dlist_remtail(EDList *l) { EDListNode *n, *np; =20 - n =3D l->tailpred; + n =3D l->tail; np =3D n->prev; if (np) { np->next =3D n->next; - l->tailpred =3D np; + l->tail =3D np; return n; } return NULL; @@ -258,7 +258,7 @@ EDListNode *e_dlist_remtail(EDList *l) =20 gint e_dlist_empty(EDList *l) { - return (l->head =3D=3D (EDListNode *)&l->tail); + return (l->head =3D=3D (EDListNode *)&l->terminator); } =20 gint e_dlist_length(EDList *l) @@ -437,7 +437,7 @@ em_cache_add(EMCache *emc, EMCacheNode *n) =20 c(printf("inserting node %s\n", n->key)); =20 - old =3D (EMCacheNode *)emc->lru_list.tailpred; + old =3D (EMCacheNode *)emc->lru_list.tail; prev =3D old->prev; while (prev && old->stamp < now - emc->timeout) { if (old->ref_count =3D=3D 0) { diff --git a/libedataserver/e-msgport.h b/libedataserver/e-msgport.h index 6e1573e..fbb9098 100644 --- a/libedataserver/e-msgport.h +++ b/libedataserver/e-msgport.h @@ -13,11 +13,11 @@ typedef struct _EDListNode { =20 typedef struct _EDList { struct _EDListNode *head; + struct _EDListNode *terminator; struct _EDListNode *tail; - struct _EDListNode *tailpred; } EDList; =20 -#define E_DLIST_INITIALISER(l) { (EDListNode *)&l.tail, NULL, (EDListNode = *)&l.head } +#define E_DLIST_INITIALISER(l) { (EDListNode *)&l.terminator, NULL, (EDLis= tNode *)&l.head } =20 void e_dlist_init(EDList *v); EDListNode *e_dlist_addhead(EDList *l, EDListNode *n); --=20 1.6.5 --=-CLQswaxdZNCRM6arpvSR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAABAgAGBQJK/4JzAAoJEDyn+gO8EoIoE38IAI5wDyFGjszc9Qow4w/XeKnF LFhgOXy5dST9bFrV6nunxb2IrLpZPWlsFPq9KB6LvwhqGlqChrhdwGKd+TxjrzZe ZiHlKN5AYnjlcXHiiB2ceOSxXquXhLquLbhB0e11vDddjziQMrX5lDg2HAGXFlY/ zeflELxOEVWl748/lCcn7/nYn4PQtesp/JvIusWeBeD0Wk9ZTSNpIzvuyuM0JaBe k1c/TM1eT6Ibu+vZRHCBcEZaWBX7SmgDhxTgI6Va5PuGPK5uNRJLo1dggInIxP0D aC8lpdCSBAIWvBaiGA8zRSh6OICXM72OhOd0HbdmaPzzkdE1fh1PofY+7kFWa+U= =I7WA -----END PGP SIGNATURE----- --=-CLQswaxdZNCRM6arpvSR-- --===============0423164086== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Evolution-patches mailing list [email protected] http://mail.gnome.org/mailman/listinfo/evolution-patches --===============0423164086==--