diff options
author | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-07 13:50:08 +0000 |
---|---|---|
committer | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-07 13:50:08 +0000 |
commit | f12ac33d46fad89af94831f16dcdebd436a851da (patch) | |
tree | 0e79ed94a2348be62f8c683421251d69bcc159f3 /src/my/my_query_helper.c | |
parent | ec817d5981e88f06f9f153cd423d13860fba4b57 (diff) | |
download | gnunet-f12ac33d46fad89af94831f16dcdebd436a851da.tar.gz gnunet-f12ac33d46fad89af94831f16dcdebd436a851da.zip |
written function cleanup
Diffstat (limited to 'src/my/my_query_helper.c')
-rw-r--r-- | src/my/my_query_helper.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c index 99bb4a5e4..cfa52b43a 100644 --- a/src/my/my_query_helper.c +++ b/src/my/my_query_helper.c | |||
@@ -62,6 +62,7 @@ GNUNET_MY_query_param_fixed_size (const void *ptr, | |||
62 | { | 62 | { |
63 | struct GNUNET_MY_QueryParam qp = { | 63 | struct GNUNET_MY_QueryParam qp = { |
64 | .conv = &my_conv_fixed_size, | 64 | .conv = &my_conv_fixed_size, |
65 | .cleaner = NULL, | ||
65 | .conv_cls = NULL, | 66 | .conv_cls = NULL, |
66 | .num_params = 1, | 67 | .num_params = 1, |
67 | .data = ptr, | 68 | .data = ptr, |
@@ -106,7 +107,6 @@ my_conv_uint16 (void *cls, | |||
106 | if (NULL == u_nbo) | 107 | if (NULL == u_nbo) |
107 | return -1; | 108 | return -1; |
108 | 109 | ||
109 | // *u_nbo = htons (*u_hbo); | ||
110 | *u_nbo = *u_hbo; | 110 | *u_nbo = *u_hbo; |
111 | 111 | ||
112 | qbind->buffer = (void *) u_nbo; | 112 | qbind->buffer = (void *) u_nbo; |
@@ -126,6 +126,7 @@ GNUNET_MY_query_param_uint16 (const uint16_t *x) | |||
126 | { | 126 | { |
127 | struct GNUNET_MY_QueryParam res = { | 127 | struct GNUNET_MY_QueryParam res = { |
128 | .conv = &my_conv_uint16, | 128 | .conv = &my_conv_uint16, |
129 | .cleaner = NULL, | ||
129 | .conv_cls = NULL, | 130 | .conv_cls = NULL, |
130 | .num_params = 1, | 131 | .num_params = 1, |
131 | .data = x, | 132 | .data = x, |
@@ -174,6 +175,7 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x) | |||
174 | { | 175 | { |
175 | struct GNUNET_MY_QueryParam res = { | 176 | struct GNUNET_MY_QueryParam res = { |
176 | .conv = &my_conv_uint32, | 177 | .conv = &my_conv_uint32, |
178 | .cleaner = NULL, | ||
177 | .conv_cls = NULL, | 179 | .conv_cls = NULL, |
178 | .num_params = 1, | 180 | .num_params = 1, |
179 | .data = x, | 181 | .data = x, |
@@ -222,6 +224,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x) | |||
222 | { | 224 | { |
223 | struct GNUNET_MY_QueryParam res = { | 225 | struct GNUNET_MY_QueryParam res = { |
224 | .conv = &my_conv_uint64, | 226 | .conv = &my_conv_uint64, |
227 | .cleaner = NULL, | ||
225 | .conv_cls = NULL, | 228 | .conv_cls = NULL, |
226 | .num_params = 1, | 229 | .num_params = 1, |
227 | .data = x, | 230 | .data = x, |
@@ -260,6 +263,27 @@ my_conv_rsa_public_key (void *cls, | |||
260 | } | 263 | } |
261 | 264 | ||
262 | 265 | ||
266 | /** | ||
267 | * Function called to clean up memory allocated | ||
268 | * by a #GNUNET_MY_ResultConverter. | ||
269 | * | ||
270 | * @param cls closure | ||
271 | * @param rd result data to clean up | ||
272 | */ | ||
273 | static void | ||
274 | my_clean_rsa_public_key (void *cls, | ||
275 | struct GNUNET_MY_QueryParam *qp) | ||
276 | { | ||
277 | struct GNUNET_CRYPTO_RsaPublicKey **pk = qp->data; | ||
278 | |||
279 | if (NULL != *pk) | ||
280 | { | ||
281 | GNUNET_CRYPTO_rsa_public_key_free (*pk); | ||
282 | *pk = NULL; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | |||
263 | /** | 287 | /** |
264 | * Generate query parameter for an RSA public key. The | 288 | * Generate query parameter for an RSA public key. The |
265 | * database must contain a BLOB type in the respective position. | 289 | * database must contain a BLOB type in the respective position. |
@@ -272,6 +296,7 @@ GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x | |||
272 | { | 296 | { |
273 | struct GNUNET_MY_QueryParam res = { | 297 | struct GNUNET_MY_QueryParam res = { |
274 | .conv = &my_conv_rsa_public_key, | 298 | .conv = &my_conv_rsa_public_key, |
299 | .cleaner = &my_clean_rsa_public_key, | ||
275 | .conv_cls = NULL, | 300 | .conv_cls = NULL, |
276 | .num_params = 1, | 301 | .num_params = 1, |
277 | .data = x, | 302 | .data = x, |
@@ -312,6 +337,27 @@ my_conv_rsa_signature (void *cls, | |||
312 | 337 | ||
313 | 338 | ||
314 | /** | 339 | /** |
340 | * Function called to clean up memory allocated | ||
341 | * by a #GNUNET_MY_QueryConverter. | ||
342 | * | ||
343 | * @param cls closure | ||
344 | * @param rd result data to clean up | ||
345 | */ | ||
346 | static void | ||
347 | my_clean_rsa_signature (void *cls, | ||
348 | struct GNUNET_MY_QueryParam *qp) | ||
349 | { | ||
350 | struct GNUNET_CRYPTO_RsaSignature **sig = qp->data; | ||
351 | |||
352 | if (NULL != *sig) | ||
353 | { | ||
354 | GNUNET_CRYPTO_rsa_signature_free (*sig); | ||
355 | *sig = NULL; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | |||
360 | /** | ||
315 | * Generate query parameter for an RSA signature. The | 361 | * Generate query parameter for an RSA signature. The |
316 | * database must contain a BLOB type in the respective position | 362 | * database must contain a BLOB type in the respective position |
317 | * | 363 | * |
@@ -323,6 +369,7 @@ GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x) | |||
323 | { | 369 | { |
324 | struct GNUNET_MY_QueryParam res = { | 370 | struct GNUNET_MY_QueryParam res = { |
325 | .conv = &my_conv_rsa_signature, | 371 | .conv = &my_conv_rsa_signature, |
372 | .cleaner = &my_clean_rsa_signature, | ||
326 | .conv_cls = NULL, | 373 | .conv_cls = NULL, |
327 | .num_params = 1, | 374 | .num_params = 1, |
328 | .data = (x), | 375 | .data = (x), |