diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-11-01 20:47:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-11-01 20:47:52 +0000 |
commit | 652e89b59ed2207c2c12172fdabcd6e659995c81 (patch) | |
tree | f054c819d483c1056e18c1099afd4c7fcd2582a0 /src/util/container_slist.c | |
parent | 5e4113e83368849500792e57946c3d8dd9e548d8 (diff) | |
download | gnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.tar.gz gnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.zip |
fixing bio testcase and a bug in bio.c, also indenting
Diffstat (limited to 'src/util/container_slist.c')
-rw-r--r-- | src/util/container_slist.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/util/container_slist.c b/src/util/container_slist.c index 3d96e26e2..4f5607a28 100644 --- a/src/util/container_slist.c +++ b/src/util/container_slist.c | |||
@@ -34,7 +34,7 @@ struct GNUNET_CONTAINER_SList_Elem | |||
34 | { | 34 | { |
35 | /** | 35 | /** |
36 | * This is a linked list. | 36 | * This is a linked list. |
37 | */ | 37 | */ |
38 | struct GNUNET_CONTAINER_SList_Elem *next; | 38 | struct GNUNET_CONTAINER_SList_Elem *next; |
39 | 39 | ||
40 | /** | 40 | /** |
@@ -102,9 +102,8 @@ struct GNUNET_CONTAINER_SList_Iterator | |||
102 | * @return a new element | 102 | * @return a new element |
103 | */ | 103 | */ |
104 | static struct GNUNET_CONTAINER_SList_Elem * | 104 | static struct GNUNET_CONTAINER_SList_Elem * |
105 | create_elem (enum GNUNET_CONTAINER_SListDisposition disp, | 105 | create_elem (enum GNUNET_CONTAINER_SListDisposition disp, |
106 | const void *buf, | 106 | const void *buf, size_t len) |
107 | size_t len) | ||
108 | { | 107 | { |
109 | struct GNUNET_CONTAINER_SList_Elem *e; | 108 | struct GNUNET_CONTAINER_SList_Elem *e; |
110 | 109 | ||
@@ -112,12 +111,12 @@ create_elem (enum GNUNET_CONTAINER_SListDisposition disp, | |||
112 | { | 111 | { |
113 | e = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList_Elem) + len); | 112 | e = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList_Elem) + len); |
114 | memcpy (&e[1], buf, len); | 113 | memcpy (&e[1], buf, len); |
115 | e->elem = (void*) &e[1]; | 114 | e->elem = (void *) &e[1]; |
116 | } | 115 | } |
117 | else | 116 | else |
118 | { | 117 | { |
119 | e = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList_Elem)); | 118 | e = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList_Elem)); |
120 | e->elem = (void*) buf; | 119 | e->elem = (void *) buf; |
121 | } | 120 | } |
122 | e->disp = disp; | 121 | e->disp = disp; |
123 | e->len = len; | 122 | e->len = len; |
@@ -133,8 +132,8 @@ create_elem (enum GNUNET_CONTAINER_SListDisposition disp, | |||
133 | * @param len length of the buffer | 132 | * @param len length of the buffer |
134 | */ | 133 | */ |
135 | void | 134 | void |
136 | GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l, | 135 | GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l, |
137 | enum GNUNET_CONTAINER_SListDisposition disp, | 136 | enum GNUNET_CONTAINER_SListDisposition disp, |
138 | const void *buf, size_t len) | 137 | const void *buf, size_t len) |
139 | { | 138 | { |
140 | struct GNUNET_CONTAINER_SList_Elem *e; | 139 | struct GNUNET_CONTAINER_SList_Elem *e; |
@@ -201,7 +200,7 @@ GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l) | |||
201 | { | 200 | { |
202 | n = e->next; | 201 | n = e->next; |
203 | if (e->disp == GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC) | 202 | if (e->disp == GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC) |
204 | GNUNET_free (e->elem); | 203 | GNUNET_free (e->elem); |
205 | GNUNET_free (e); | 204 | GNUNET_free (e); |
206 | e = n; | 205 | e = n; |
207 | } | 206 | } |
@@ -224,8 +223,7 @@ GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l, | |||
224 | struct GNUNET_CONTAINER_SList_Elem *e; | 223 | struct GNUNET_CONTAINER_SList_Elem *e; |
225 | 224 | ||
226 | for (e = l->head; e != NULL; e = e->next) | 225 | for (e = l->head; e != NULL; e = e->next) |
227 | if ( (e->len == len) && | 226 | if ((e->len == len) && (memcmp (buf, e->elem, len) == 0)) |
228 | (memcmp (buf, e->elem, len) == 0) ) | ||
229 | return GNUNET_YES; | 227 | return GNUNET_YES; |
230 | return GNUNET_NO; | 228 | return GNUNET_NO; |
231 | } | 229 | } |
@@ -275,8 +273,8 @@ GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i) | |||
275 | */ | 273 | */ |
276 | void | 274 | void |
277 | GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before, | 275 | GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before, |
278 | enum GNUNET_CONTAINER_SListDisposition disp, | 276 | enum GNUNET_CONTAINER_SListDisposition disp, |
279 | const void *buf, size_t len) | 277 | const void *buf, size_t len) |
280 | { | 278 | { |
281 | struct GNUNET_CONTAINER_SList_Elem *e; | 279 | struct GNUNET_CONTAINER_SList_Elem *e; |
282 | 280 | ||