diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-12 19:07:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-12 19:07:40 +0000 |
commit | 6c471eeb15e27f8226492b4860a3c2acb94c5f25 (patch) | |
tree | a3a9dcba12ee5356c03056c10b7aba5367b2ef34 /src/datacache | |
parent | 16bcbbea7133fd2265d46bd2ae1dc70e8c9ba96f (diff) | |
download | gnunet-6c471eeb15e27f8226492b4860a3c2acb94c5f25.tar.gz gnunet-6c471eeb15e27f8226492b4860a3c2acb94c5f25.zip |
-consistently use struct GNUNET_HashCode
Diffstat (limited to 'src/datacache')
-rw-r--r-- | src/datacache/datacache.c | 6 | ||||
-rw-r--r-- | src/datacache/perf_datacache.c | 18 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_mysql.c | 46 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_postgres.c | 16 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 18 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_template.c | 4 | ||||
-rw-r--r-- | src/datacache/test_datacache.c | 24 | ||||
-rw-r--r-- | src/datacache/test_datacache_quota.c | 12 |
8 files changed, 72 insertions, 72 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index b440af1b2..9087ae0dd 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c | |||
@@ -103,7 +103,7 @@ struct GNUNET_DATACACHE_Handle | |||
103 | * @param size number of bytes that were made available | 103 | * @param size number of bytes that were made available |
104 | */ | 104 | */ |
105 | static void | 105 | static void |
106 | env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size) | 106 | env_delete_notify (void *cls, const struct GNUNET_HashCode * key, size_t size) |
107 | { | 107 | { |
108 | struct GNUNET_DATACACHE_Handle *h = cls; | 108 | struct GNUNET_DATACACHE_Handle *h = cls; |
109 | 109 | ||
@@ -233,7 +233,7 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) | |||
233 | */ | 233 | */ |
234 | int | 234 | int |
235 | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | 235 | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, |
236 | const GNUNET_HashCode * key, size_t size, | 236 | const struct GNUNET_HashCode * key, size_t size, |
237 | const char *data, enum GNUNET_BLOCK_Type type, | 237 | const char *data, enum GNUNET_BLOCK_Type type, |
238 | struct GNUNET_TIME_Absolute discard_time) | 238 | struct GNUNET_TIME_Absolute discard_time) |
239 | { | 239 | { |
@@ -270,7 +270,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
270 | */ | 270 | */ |
271 | unsigned int | 271 | unsigned int |
272 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | 272 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, |
273 | const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, | 273 | const struct GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, |
274 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) | 274 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) |
275 | { | 275 | { |
276 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1, | 276 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1, |
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index 94cd7a58e..fd3891116 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c | |||
@@ -45,10 +45,10 @@ static const char *plugin_name; | |||
45 | 45 | ||
46 | static int | 46 | static int |
47 | checkIt (void *cls, struct GNUNET_TIME_Absolute exp, | 47 | checkIt (void *cls, struct GNUNET_TIME_Absolute exp, |
48 | const GNUNET_HashCode * key, size_t size, const char *data, | 48 | const struct GNUNET_HashCode * key, size_t size, const char *data, |
49 | enum GNUNET_BLOCK_Type type) | 49 | enum GNUNET_BLOCK_Type type) |
50 | { | 50 | { |
51 | if ((size == sizeof (GNUNET_HashCode)) && (0 == memcmp (data, cls, size))) | 51 | if ((size == sizeof (struct GNUNET_HashCode)) && (0 == memcmp (data, cls, size))) |
52 | found++; | 52 | found++; |
53 | return GNUNET_OK; | 53 | return GNUNET_OK; |
54 | } | 54 | } |
@@ -59,8 +59,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
59 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 59 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
60 | { | 60 | { |
61 | struct GNUNET_DATACACHE_Handle *h; | 61 | struct GNUNET_DATACACHE_Handle *h; |
62 | GNUNET_HashCode k; | 62 | struct GNUNET_HashCode k; |
63 | GNUNET_HashCode n; | 63 | struct GNUNET_HashCode n; |
64 | struct GNUNET_TIME_Absolute exp; | 64 | struct GNUNET_TIME_Absolute exp; |
65 | struct GNUNET_TIME_Absolute start; | 65 | struct GNUNET_TIME_Absolute start; |
66 | unsigned int i; | 66 | unsigned int i; |
@@ -76,14 +76,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
76 | } | 76 | } |
77 | exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); | 77 | exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); |
78 | start = GNUNET_TIME_absolute_get (); | 78 | start = GNUNET_TIME_absolute_get (); |
79 | memset (&k, 0, sizeof (GNUNET_HashCode)); | 79 | memset (&k, 0, sizeof (struct GNUNET_HashCode)); |
80 | for (i = 0; i < ITERATIONS; i++) | 80 | for (i = 0; i < ITERATIONS; i++) |
81 | { | 81 | { |
82 | if (0 == i % (ITERATIONS / 80)) | 82 | if (0 == i % (ITERATIONS / 80)) |
83 | FPRINTF (stderr, "%s", "."); | 83 | FPRINTF (stderr, "%s", "."); |
84 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 84 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
85 | ASSERT (GNUNET_OK == | 85 | ASSERT (GNUNET_OK == |
86 | GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode), | 86 | GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode), |
87 | (const char *) &n, 1 + i % 16, exp)); | 87 | (const char *) &n, 1 + i % 16, exp)); |
88 | k = n; | 88 | k = n; |
89 | } | 89 | } |
@@ -96,12 +96,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
96 | GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS, | 96 | GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS, |
97 | "ms/item"); | 97 | "ms/item"); |
98 | start = GNUNET_TIME_absolute_get (); | 98 | start = GNUNET_TIME_absolute_get (); |
99 | memset (&k, 0, sizeof (GNUNET_HashCode)); | 99 | memset (&k, 0, sizeof (struct GNUNET_HashCode)); |
100 | for (i = 0; i < ITERATIONS; i++) | 100 | for (i = 0; i < ITERATIONS; i++) |
101 | { | 101 | { |
102 | if (0 == i % (ITERATIONS / 80)) | 102 | if (0 == i % (ITERATIONS / 80)) |
103 | FPRINTF (stderr, "%s", "."); | 103 | FPRINTF (stderr, "%s", "."); |
104 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 104 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
105 | GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n); | 105 | GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n); |
106 | k = n; | 106 | k = n; |
107 | } | 107 | } |
diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c index 810342908..1457eddfb 100644 --- a/src/datacache/plugin_datacache_mysql.c +++ b/src/datacache/plugin_datacache_mysql.c | |||
@@ -87,7 +87,7 @@ | |||
87 | /** | 87 | /** |
88 | * Estimate of the per-entry overhead (including indices). | 88 | * Estimate of the per-entry overhead (including indices). |
89 | */ | 89 | */ |
90 | #define OVERHEAD ((4*2+4*2+8*2+8*2+sizeof(GNUNET_HashCode)*5+8)) | 90 | #define OVERHEAD ((4*2+4*2+8*2+8*2+sizeof(struct GNUNET_HashCode)*5+8)) |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Die with an error message that indicates | 93 | * Die with an error message that indicates |
@@ -190,7 +190,7 @@ itable (struct Plugin *plugin) | |||
190 | * @return 0 on error, number of bytes used otherwise | 190 | * @return 0 on error, number of bytes used otherwise |
191 | */ | 191 | */ |
192 | static size_t | 192 | static size_t |
193 | mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | 193 | mysql_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, |
194 | const char *data, enum GNUNET_BLOCK_Type type, | 194 | const char *data, enum GNUNET_BLOCK_Type type, |
195 | struct GNUNET_TIME_Absolute discard_time) | 195 | struct GNUNET_TIME_Absolute discard_time) |
196 | { | 196 | { |
@@ -202,7 +202,7 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
202 | unsigned long long v_now; | 202 | unsigned long long v_now; |
203 | unsigned long long v_discard_time; | 203 | unsigned long long v_discard_time; |
204 | unsigned int v_type; | 204 | unsigned int v_type; |
205 | GNUNET_HashCode vhash; | 205 | struct GNUNET_HashCode vhash; |
206 | int ret; | 206 | int ret; |
207 | 207 | ||
208 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE) | 208 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE) |
@@ -211,8 +211,8 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
211 | now = GNUNET_TIME_absolute_get (); | 211 | now = GNUNET_TIME_absolute_get (); |
212 | 212 | ||
213 | /* first try UPDATE */ | 213 | /* first try UPDATE */ |
214 | h_length = sizeof (GNUNET_HashCode); | 214 | h_length = sizeof (struct GNUNET_HashCode); |
215 | k_length = sizeof (GNUNET_HashCode); | 215 | k_length = sizeof (struct GNUNET_HashCode); |
216 | v_length = size; | 216 | v_length = size; |
217 | v_type = type; | 217 | v_type = type; |
218 | v_now = (unsigned long long) now.abs_value; | 218 | v_now = (unsigned long long) now.abs_value; |
@@ -221,15 +221,15 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
221 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_value, NULL, | 221 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_value, NULL, |
222 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 222 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
223 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, | 223 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, |
224 | MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode), | 224 | MYSQL_TYPE_BLOB, key, sizeof (struct GNUNET_HashCode), |
225 | &k_length, MYSQL_TYPE_BLOB, &vhash, | 225 | &k_length, MYSQL_TYPE_BLOB, &vhash, |
226 | sizeof (GNUNET_HashCode), &h_length, | 226 | sizeof (struct GNUNET_HashCode), &h_length, |
227 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, -1)) | 227 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, -1)) |
228 | return GNUNET_OK; | 228 | return GNUNET_OK; |
229 | 229 | ||
230 | /* now try INSERT */ | 230 | /* now try INSERT */ |
231 | h_length = sizeof (GNUNET_HashCode); | 231 | h_length = sizeof (struct GNUNET_HashCode); |
232 | k_length = sizeof (GNUNET_HashCode); | 232 | k_length = sizeof (struct GNUNET_HashCode); |
233 | v_length = size; | 233 | v_length = size; |
234 | if (GNUNET_OK != | 234 | if (GNUNET_OK != |
235 | (ret = | 235 | (ret = |
@@ -237,9 +237,9 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
237 | MYSQL_TYPE_LONG, &type, GNUNET_YES, | 237 | MYSQL_TYPE_LONG, &type, GNUNET_YES, |
238 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 238 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
239 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, | 239 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, |
240 | MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode), | 240 | MYSQL_TYPE_BLOB, key, sizeof (struct GNUNET_HashCode), |
241 | &k_length, MYSQL_TYPE_BLOB, &vhash, | 241 | &k_length, MYSQL_TYPE_BLOB, &vhash, |
242 | sizeof (GNUNET_HashCode), &h_length, | 242 | sizeof (struct GNUNET_HashCode), &h_length, |
243 | MYSQL_TYPE_BLOB, data, (unsigned long) size, | 243 | MYSQL_TYPE_BLOB, data, (unsigned long) size, |
244 | &v_length, -1))) | 244 | &v_length, -1))) |
245 | { | 245 | { |
@@ -270,7 +270,7 @@ return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) | |||
270 | * @return the number of results found | 270 | * @return the number of results found |
271 | */ | 271 | */ |
272 | static unsigned int | 272 | static unsigned int |
273 | mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | 273 | mysql_plugin_get (void *cls, const struct GNUNET_HashCode * key, |
274 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, | 274 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, |
275 | void *iter_cls) | 275 | void *iter_cls) |
276 | { | 276 | { |
@@ -290,7 +290,7 @@ mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
290 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 290 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; |
291 | 291 | ||
292 | now = GNUNET_TIME_absolute_get (); | 292 | now = GNUNET_TIME_absolute_get (); |
293 | h_length = sizeof (GNUNET_HashCode); | 293 | h_length = sizeof (struct GNUNET_HashCode); |
294 | v_length = sizeof (buffer); | 294 | v_length = sizeof (buffer); |
295 | total = -1; | 295 | total = -1; |
296 | memset (rbind, 0, sizeof (rbind)); | 296 | memset (rbind, 0, sizeof (rbind)); |
@@ -303,7 +303,7 @@ mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
303 | (ret = | 303 | (ret = |
304 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->count_value, 1, rbind, | 304 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->count_value, 1, rbind, |
305 | return_ok, NULL, MYSQL_TYPE_BLOB, key, | 305 | return_ok, NULL, MYSQL_TYPE_BLOB, key, |
306 | sizeof (GNUNET_HashCode), &h_length, | 306 | sizeof (struct GNUNET_HashCode), &h_length, |
307 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, | 307 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, |
308 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 308 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
309 | -1))) || (-1 == total)) | 309 | -1))) || (-1 == total)) |
@@ -332,7 +332,7 @@ mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
332 | (ret = | 332 | (ret = |
333 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->select_value, 2, rbind, | 333 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->select_value, 2, rbind, |
334 | return_ok, NULL, MYSQL_TYPE_BLOB, key, | 334 | return_ok, NULL, MYSQL_TYPE_BLOB, key, |
335 | sizeof (GNUNET_HashCode), &h_length, | 335 | sizeof (struct GNUNET_HashCode), &h_length, |
336 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, | 336 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, |
337 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 337 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
338 | MYSQL_TYPE_LONG, &off, GNUNET_YES, -1))) | 338 | MYSQL_TYPE_LONG, &off, GNUNET_YES, -1))) |
@@ -364,24 +364,24 @@ mysql_plugin_del (void *cls) | |||
364 | 364 | ||
365 | MYSQL_BIND rbind[5]; | 365 | MYSQL_BIND rbind[5]; |
366 | unsigned int v_type; | 366 | unsigned int v_type; |
367 | GNUNET_HashCode v_key; | 367 | struct GNUNET_HashCode v_key; |
368 | GNUNET_HashCode vhash; | 368 | struct GNUNET_HashCode vhash; |
369 | unsigned long k_length; | 369 | unsigned long k_length; |
370 | unsigned long h_length; | 370 | unsigned long h_length; |
371 | unsigned long v_length; | 371 | unsigned long v_length; |
372 | int ret; | 372 | int ret; |
373 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 373 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; |
374 | 374 | ||
375 | k_length = sizeof (GNUNET_HashCode); | 375 | k_length = sizeof (struct GNUNET_HashCode); |
376 | h_length = sizeof (GNUNET_HashCode); | 376 | h_length = sizeof (struct GNUNET_HashCode); |
377 | v_length = sizeof (buffer); | 377 | v_length = sizeof (buffer); |
378 | memset (rbind, 0, sizeof (rbind)); | 378 | memset (rbind, 0, sizeof (rbind)); |
379 | rbind[0].buffer_type = MYSQL_TYPE_BLOB; | 379 | rbind[0].buffer_type = MYSQL_TYPE_BLOB; |
380 | rbind[0].buffer_length = sizeof (GNUNET_HashCode); | 380 | rbind[0].buffer_length = sizeof (struct GNUNET_HashCode); |
381 | rbind[0].length = &k_length; | 381 | rbind[0].length = &k_length; |
382 | rbind[0].buffer = &v_key; | 382 | rbind[0].buffer = &v_key; |
383 | rbind[1].buffer_type = MYSQL_TYPE_BLOB; | 383 | rbind[1].buffer_type = MYSQL_TYPE_BLOB; |
384 | rbind[1].buffer_length = sizeof (GNUNET_HashCode); | 384 | rbind[1].buffer_length = sizeof (struct GNUNET_HashCode); |
385 | rbind[1].length = &h_length; | 385 | rbind[1].length = &h_length; |
386 | rbind[1].buffer = &vhash; | 386 | rbind[1].buffer = &vhash; |
387 | rbind[2].buffer_type = MYSQL_TYPE_LONG; | 387 | rbind[2].buffer_type = MYSQL_TYPE_LONG; |
@@ -399,9 +399,9 @@ mysql_plugin_del (void *cls) | |||
399 | (ret = | 399 | (ret = |
400 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->delete_value, NULL, | 400 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->delete_value, NULL, |
401 | MYSQL_TYPE_BLOB, &v_key, | 401 | MYSQL_TYPE_BLOB, &v_key, |
402 | sizeof (GNUNET_HashCode), &k_length, | 402 | sizeof (struct GNUNET_HashCode), &k_length, |
403 | MYSQL_TYPE_BLOB, &vhash, | 403 | MYSQL_TYPE_BLOB, &vhash, |
404 | sizeof (GNUNET_HashCode), &h_length, | 404 | sizeof (struct GNUNET_HashCode), &h_length, |
405 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, | 405 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, |
406 | MYSQL_TYPE_BLOB, buffer, | 406 | MYSQL_TYPE_BLOB, buffer, |
407 | (unsigned long) sizeof (buffer), &v_length, | 407 | (unsigned long) sizeof (buffer), &v_length, |
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index b40f1fd04..e9157742c 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c | |||
@@ -34,7 +34,7 @@ | |||
34 | /** | 34 | /** |
35 | * Per-entry overhead estimate | 35 | * Per-entry overhead estimate |
36 | */ | 36 | */ |
37 | #define OVERHEAD (sizeof(GNUNET_HashCode) + 24) | 37 | #define OVERHEAD (sizeof(struct GNUNET_HashCode) + 24) |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Context for all functions in this plugin. | 40 | * Context for all functions in this plugin. |
@@ -160,7 +160,7 @@ init_connection (struct Plugin *plugin) | |||
160 | * @return 0 on error, number of bytes used otherwise | 160 | * @return 0 on error, number of bytes used otherwise |
161 | */ | 161 | */ |
162 | static size_t | 162 | static size_t |
163 | postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | 163 | postgres_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, |
164 | const char *data, enum GNUNET_BLOCK_Type type, | 164 | const char *data, enum GNUNET_BLOCK_Type type, |
165 | struct GNUNET_TIME_Absolute discard_time) | 165 | struct GNUNET_TIME_Absolute discard_time) |
166 | { | 166 | { |
@@ -178,7 +178,7 @@ postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
178 | int paramLengths[] = { | 178 | int paramLengths[] = { |
179 | sizeof (btype), | 179 | sizeof (btype), |
180 | sizeof (bexpi), | 180 | sizeof (bexpi), |
181 | sizeof (GNUNET_HashCode), | 181 | sizeof (struct GNUNET_HashCode), |
182 | size | 182 | size |
183 | }; | 183 | }; |
184 | const int paramFormats[] = { 1, 1, 1, 1 }; | 184 | const int paramFormats[] = { 1, 1, 1, 1 }; |
@@ -206,7 +206,7 @@ postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
206 | * @return the number of results found | 206 | * @return the number of results found |
207 | */ | 207 | */ |
208 | static unsigned int | 208 | static unsigned int |
209 | postgres_plugin_get (void *cls, const GNUNET_HashCode * key, | 209 | postgres_plugin_get (void *cls, const struct GNUNET_HashCode * key, |
210 | enum GNUNET_BLOCK_Type type, | 210 | enum GNUNET_BLOCK_Type type, |
211 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) | 211 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) |
212 | { | 212 | { |
@@ -218,7 +218,7 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
218 | (const char *) &btype, | 218 | (const char *) &btype, |
219 | }; | 219 | }; |
220 | int paramLengths[] = { | 220 | int paramLengths[] = { |
221 | sizeof (GNUNET_HashCode), | 221 | sizeof (struct GNUNET_HashCode), |
222 | sizeof (btype), | 222 | sizeof (btype), |
223 | }; | 223 | }; |
224 | const int paramFormats[] = { 1, 1 }; | 224 | const int paramFormats[] = { 1, 1 }; |
@@ -298,7 +298,7 @@ postgres_plugin_del (void *cls) | |||
298 | struct Plugin *plugin = cls; | 298 | struct Plugin *plugin = cls; |
299 | uint32_t size; | 299 | uint32_t size; |
300 | uint32_t oid; | 300 | uint32_t oid; |
301 | GNUNET_HashCode key; | 301 | struct GNUNET_HashCode key; |
302 | PGresult *res; | 302 | PGresult *res; |
303 | 303 | ||
304 | res = PQexecPrepared (plugin->dbh, "getm", 0, NULL, NULL, NULL, 1); | 304 | res = PQexecPrepared (plugin->dbh, "getm", 0, NULL, NULL, NULL, 1); |
@@ -319,7 +319,7 @@ postgres_plugin_del (void *cls) | |||
319 | } | 319 | } |
320 | if ((3 != PQnfields (res)) || (sizeof (size) != PQfsize (res, 0)) || | 320 | if ((3 != PQnfields (res)) || (sizeof (size) != PQfsize (res, 0)) || |
321 | (sizeof (oid) != PQfsize (res, 1)) || | 321 | (sizeof (oid) != PQfsize (res, 1)) || |
322 | (sizeof (GNUNET_HashCode) != PQgetlength (res, 0, 2))) | 322 | (sizeof (struct GNUNET_HashCode) != PQgetlength (res, 0, 2))) |
323 | { | 323 | { |
324 | GNUNET_break (0); | 324 | GNUNET_break (0); |
325 | PQclear (res); | 325 | PQclear (res); |
@@ -327,7 +327,7 @@ postgres_plugin_del (void *cls) | |||
327 | } | 327 | } |
328 | size = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0)); | 328 | size = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0)); |
329 | oid = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1)); | 329 | oid = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1)); |
330 | memcpy (&key, PQgetvalue (res, 0, 2), sizeof (GNUNET_HashCode)); | 330 | memcpy (&key, PQgetvalue (res, 0, 2), sizeof (struct GNUNET_HashCode)); |
331 | PQclear (res); | 331 | PQclear (res); |
332 | if (GNUNET_OK != GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, "delrow", oid)) | 332 | if (GNUNET_OK != GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, "delrow", oid)) |
333 | return GNUNET_SYSERR; | 333 | return GNUNET_SYSERR; |
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index db27de3e2..26792e1fb 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -37,7 +37,7 @@ | |||
37 | * How much overhead do we assume per entry in the | 37 | * How much overhead do we assume per entry in the |
38 | * datacache? | 38 | * datacache? |
39 | */ | 39 | */ |
40 | #define OVERHEAD (sizeof(GNUNET_HashCode) + 32) | 40 | #define OVERHEAD (sizeof(struct GNUNET_HashCode) + 32) |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Context for all functions in this plugin. | 43 | * Context for all functions in this plugin. |
@@ -98,7 +98,7 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded | |||
98 | * @return 0 on error, number of bytes used otherwise | 98 | * @return 0 on error, number of bytes used otherwise |
99 | */ | 99 | */ |
100 | static size_t | 100 | static size_t |
101 | sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | 101 | sqlite_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, |
102 | const char *data, enum GNUNET_BLOCK_Type type, | 102 | const char *data, enum GNUNET_BLOCK_Type type, |
103 | struct GNUNET_TIME_Absolute discard_time) | 103 | struct GNUNET_TIME_Absolute discard_time) |
104 | { | 104 | { |
@@ -126,7 +126,7 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
126 | if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) || | 126 | if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) || |
127 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) || | 127 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) || |
128 | (SQLITE_OK != | 128 | (SQLITE_OK != |
129 | sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode), | 129 | sqlite3_bind_blob (stmt, 3, key, sizeof (struct GNUNET_HashCode), |
130 | SQLITE_TRANSIENT)) || | 130 | SQLITE_TRANSIENT)) || |
131 | (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT))) | 131 | (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT))) |
132 | { | 132 | { |
@@ -161,7 +161,7 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
161 | * @return the number of results found | 161 | * @return the number of results found |
162 | */ | 162 | */ |
163 | static unsigned int | 163 | static unsigned int |
164 | sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, | 164 | sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, |
165 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, | 165 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, |
166 | void *iter_cls) | 166 | void *iter_cls) |
167 | { | 167 | { |
@@ -192,7 +192,7 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
192 | ntime = (int64_t) now.abs_value; | 192 | ntime = (int64_t) now.abs_value; |
193 | GNUNET_assert (ntime >= 0); | 193 | GNUNET_assert (ntime >= 0); |
194 | if ((SQLITE_OK != | 194 | if ((SQLITE_OK != |
195 | sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), | 195 | sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode), |
196 | SQLITE_TRANSIENT)) || | 196 | SQLITE_TRANSIENT)) || |
197 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || | 197 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || |
198 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) | 198 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) |
@@ -239,7 +239,7 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
239 | return cnt; | 239 | return cnt; |
240 | } | 240 | } |
241 | if ((SQLITE_OK != | 241 | if ((SQLITE_OK != |
242 | sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), | 242 | sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode), |
243 | SQLITE_TRANSIENT)) || | 243 | SQLITE_TRANSIENT)) || |
244 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || | 244 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || |
245 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) | 245 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) |
@@ -287,7 +287,7 @@ sqlite_plugin_del (void *cls) | |||
287 | unsigned int dsize; | 287 | unsigned int dsize; |
288 | sqlite3_stmt *stmt; | 288 | sqlite3_stmt *stmt; |
289 | sqlite3_stmt *dstmt; | 289 | sqlite3_stmt *dstmt; |
290 | GNUNET_HashCode hc; | 290 | struct GNUNET_HashCode hc; |
291 | 291 | ||
292 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL"); | 292 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL"); |
293 | stmt = NULL; | 293 | stmt = NULL; |
@@ -311,8 +311,8 @@ sqlite_plugin_del (void *cls) | |||
311 | return GNUNET_SYSERR; | 311 | return GNUNET_SYSERR; |
312 | } | 312 | } |
313 | rowid = sqlite3_column_int64 (stmt, 0); | 313 | rowid = sqlite3_column_int64 (stmt, 0); |
314 | GNUNET_assert (sqlite3_column_bytes (stmt, 1) == sizeof (GNUNET_HashCode)); | 314 | GNUNET_assert (sqlite3_column_bytes (stmt, 1) == sizeof (struct GNUNET_HashCode)); |
315 | memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (GNUNET_HashCode)); | 315 | memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (struct GNUNET_HashCode)); |
316 | dsize = sqlite3_column_bytes (stmt, 2); | 316 | dsize = sqlite3_column_bytes (stmt, 2); |
317 | if (SQLITE_OK != sqlite3_finalize (stmt)) | 317 | if (SQLITE_OK != sqlite3_finalize (stmt)) |
318 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 318 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index 2d3f160e4..6c4395982 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c | |||
@@ -52,7 +52,7 @@ struct Plugin | |||
52 | * @return 0 on error, number of bytes used otherwise | 52 | * @return 0 on error, number of bytes used otherwise |
53 | */ | 53 | */ |
54 | static size_t | 54 | static size_t |
55 | template_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | 55 | template_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, |
56 | const char *data, enum GNUNET_BLOCK_Type type, | 56 | const char *data, enum GNUNET_BLOCK_Type type, |
57 | struct GNUNET_TIME_Absolute discard_time) | 57 | struct GNUNET_TIME_Absolute discard_time) |
58 | { | 58 | { |
@@ -73,7 +73,7 @@ template_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
73 | * @return the number of results found | 73 | * @return the number of results found |
74 | */ | 74 | */ |
75 | static unsigned int | 75 | static unsigned int |
76 | template_plugin_get (void *cls, const GNUNET_HashCode * key, | 76 | template_plugin_get (void *cls, const struct GNUNET_HashCode * key, |
77 | enum GNUNET_BLOCK_Type type, | 77 | enum GNUNET_BLOCK_Type type, |
78 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) | 78 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) |
79 | { | 79 | { |
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index c818daaa8..1d8cd3295 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c | |||
@@ -39,10 +39,10 @@ static const char *plugin_name; | |||
39 | 39 | ||
40 | static int | 40 | static int |
41 | checkIt (void *cls, struct GNUNET_TIME_Absolute exp, | 41 | checkIt (void *cls, struct GNUNET_TIME_Absolute exp, |
42 | const GNUNET_HashCode * key, size_t size, const char *data, | 42 | const struct GNUNET_HashCode * key, size_t size, const char *data, |
43 | enum GNUNET_BLOCK_Type type) | 43 | enum GNUNET_BLOCK_Type type) |
44 | { | 44 | { |
45 | if (size != sizeof (GNUNET_HashCode)) | 45 | if (size != sizeof (struct GNUNET_HashCode)) |
46 | { | 46 | { |
47 | GNUNET_break (0); | 47 | GNUNET_break (0); |
48 | ok = 2; | 48 | ok = 2; |
@@ -61,8 +61,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
61 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 61 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
62 | { | 62 | { |
63 | struct GNUNET_DATACACHE_Handle *h; | 63 | struct GNUNET_DATACACHE_Handle *h; |
64 | GNUNET_HashCode k; | 64 | struct GNUNET_HashCode k; |
65 | GNUNET_HashCode n; | 65 | struct GNUNET_HashCode n; |
66 | struct GNUNET_TIME_Absolute exp; | 66 | struct GNUNET_TIME_Absolute exp; |
67 | unsigned int i; | 67 | unsigned int i; |
68 | 68 | ||
@@ -77,27 +77,27 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
77 | } | 77 | } |
78 | exp = GNUNET_TIME_absolute_get (); | 78 | exp = GNUNET_TIME_absolute_get (); |
79 | exp.abs_value += 5 * 60 * 1000; | 79 | exp.abs_value += 5 * 60 * 1000; |
80 | memset (&k, 0, sizeof (GNUNET_HashCode)); | 80 | memset (&k, 0, sizeof (struct GNUNET_HashCode)); |
81 | for (i = 0; i < 100; i++) | 81 | for (i = 0; i < 100; i++) |
82 | { | 82 | { |
83 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 83 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
84 | ASSERT (GNUNET_OK == | 84 | ASSERT (GNUNET_OK == |
85 | GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode), | 85 | GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode), |
86 | (const char *) &n, 1 + i % 16, exp)); | 86 | (const char *) &n, 1 + i % 16, exp)); |
87 | k = n; | 87 | k = n; |
88 | } | 88 | } |
89 | memset (&k, 0, sizeof (GNUNET_HashCode)); | 89 | memset (&k, 0, sizeof (struct GNUNET_HashCode)); |
90 | for (i = 0; i < 100; i++) | 90 | for (i = 0; i < 100; i++) |
91 | { | 91 | { |
92 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 92 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
93 | ASSERT (1 == GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n)); | 93 | ASSERT (1 == GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n)); |
94 | k = n; | 94 | k = n; |
95 | } | 95 | } |
96 | 96 | ||
97 | memset (&k, 42, sizeof (GNUNET_HashCode)); | 97 | memset (&k, 42, sizeof (struct GNUNET_HashCode)); |
98 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 98 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
99 | ASSERT (GNUNET_OK == | 99 | ASSERT (GNUNET_OK == |
100 | GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode), | 100 | GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode), |
101 | (const char *) &n, 792, | 101 | (const char *) &n, 792, |
102 | GNUNET_TIME_UNIT_FOREVER_ABS)); | 102 | GNUNET_TIME_UNIT_FOREVER_ABS)); |
103 | ASSERT (0 != GNUNET_DATACACHE_get (h, &k, 792, &checkIt, &n)); | 103 | ASSERT (0 != GNUNET_DATACACHE_get (h, &k, 792, &checkIt, &n)); |
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c index 5325b398f..1f252c14a 100644 --- a/src/datacache/test_datacache_quota.c +++ b/src/datacache/test_datacache_quota.c | |||
@@ -47,8 +47,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
47 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 47 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
48 | { | 48 | { |
49 | struct GNUNET_DATACACHE_Handle *h; | 49 | struct GNUNET_DATACACHE_Handle *h; |
50 | GNUNET_HashCode k; | 50 | struct GNUNET_HashCode k; |
51 | GNUNET_HashCode n; | 51 | struct GNUNET_HashCode n; |
52 | unsigned int i; | 52 | unsigned int i; |
53 | unsigned int j; | 53 | unsigned int j; |
54 | char buf[3200]; | 54 | char buf[3200]; |
@@ -64,11 +64,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
64 | } | 64 | } |
65 | exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); | 65 | exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); |
66 | memset (buf, 1, sizeof (buf)); | 66 | memset (buf, 1, sizeof (buf)); |
67 | memset (&k, 0, sizeof (GNUNET_HashCode)); | 67 | memset (&k, 0, sizeof (struct GNUNET_HashCode)); |
68 | for (i = 0; i < 10; i++) | 68 | for (i = 0; i < 10; i++) |
69 | { | 69 | { |
70 | FPRINTF (stderr, "%s", "."); | 70 | FPRINTF (stderr, "%s", "."); |
71 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 71 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
72 | for (j = i; j < sizeof (buf); j += 10) | 72 | for (j = i; j < sizeof (buf); j += 10) |
73 | { | 73 | { |
74 | exp.abs_value++; | 74 | exp.abs_value++; |
@@ -79,11 +79,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
79 | k = n; | 79 | k = n; |
80 | } | 80 | } |
81 | FPRINTF (stderr, "%s", "\n"); | 81 | FPRINTF (stderr, "%s", "\n"); |
82 | memset (&k, 0, sizeof (GNUNET_HashCode)); | 82 | memset (&k, 0, sizeof (struct GNUNET_HashCode)); |
83 | for (i = 0; i < 10; i++) | 83 | for (i = 0; i < 10; i++) |
84 | { | 84 | { |
85 | FPRINTF (stderr, "%s", "."); | 85 | FPRINTF (stderr, "%s", "."); |
86 | GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); | 86 | GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n); |
87 | if (i < 2) | 87 | if (i < 2) |
88 | ASSERT (0 == GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL)); | 88 | ASSERT (0 == GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL)); |
89 | if (i == 9) | 89 | if (i == 9) |