aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_record_serialization.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-01 12:30:18 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-01 12:30:18 +0000
commit206054928a4b151286d4af3eba3665b2b4d24155 (patch)
tree2dd0cc3b1daaac19875f90d5482b55fac60cc74e /src/namestore/test_namestore_record_serialization.c
parentc54fafbf68d883d700f05dfa759a47c36938809b (diff)
downloadgnunet-206054928a4b151286d4af3eba3665b2b4d24155.tar.gz
gnunet-206054928a4b151286d4af3eba3665b2b4d24155.zip
- at least compiling
Diffstat (limited to 'src/namestore/test_namestore_record_serialization.c')
-rw-r--r--src/namestore/test_namestore_record_serialization.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/namestore/test_namestore_record_serialization.c b/src/namestore/test_namestore_record_serialization.c
index cd60a5dda..b389e7faf 100644
--- a/src/namestore/test_namestore_record_serialization.c
+++ b/src/namestore/test_namestore_record_serialization.c
@@ -36,15 +36,12 @@ static void
36run (void *cls, char *const *args, const char *cfgfile, 36run (void *cls, char *const *args, const char *cfgfile,
37 const struct GNUNET_CONFIGURATION_Handle *cfg) 37 const struct GNUNET_CONFIGURATION_Handle *cfg)
38{ 38{
39 char * rd_ser = NULL;
40 size_t len; 39 size_t len;
41 int c; 40 int c;
42 int dst_elem = 0;
43 41
44 int rd_count = 3; 42 int rd_count = 3;
45 size_t data_len; 43 size_t data_len;
46 struct GNUNET_NAMESTORE_RecordData src[rd_count]; 44 struct GNUNET_NAMESTORE_RecordData src[rd_count];
47 struct GNUNET_NAMESTORE_RecordData *dst = NULL;
48 45
49 memset(src, '\0', rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData)); 46 memset(src, '\0', rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData));
50 47
@@ -61,18 +58,20 @@ run (void *cls, char *const *args, const char *cfgfile,
61 } 58 }
62 res = 0; 59 res = 0;
63 60
64 len = GNUNET_NAMESTORE_records_serialize (&rd_ser, rd_count, src); 61 len = GNUNET_NAMESTORE_records_get_size(rd_count, src);
62 char rd_ser[len];
63 GNUNET_assert (len == GNUNET_NAMESTORE_records_serialize(rd_count, src, len, rd_ser));
64
65 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Serialized data len: %u\n",len); 65 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Serialized data len: %u\n",len);
66 66
67 GNUNET_assert (rd_ser != NULL); 67 GNUNET_assert (rd_ser != NULL);
68 68
69 dst_elem = GNUNET_NAMESTORE_records_deserialize(&dst, rd_ser, len); 69 struct GNUNET_NAMESTORE_RecordData dst[rd_count];
70 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deserialized elements: %u\n",dst_elem); 70 GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_records_deserialize (len, rd_ser, rd_count, dst));
71 71
72 GNUNET_assert (dst_elem == rd_count);
73 GNUNET_assert (dst != NULL); 72 GNUNET_assert (dst != NULL);
74 73
75 for (c = 0; c < dst_elem; c++) 74 for (c = 0; c < rd_count; c++)
76 { 75 {
77 if (src[c].data_size != dst[c].data_size) 76 if (src[c].data_size != dst[c].data_size)
78 { 77 {
@@ -116,11 +115,6 @@ run (void *cls, char *const *args, const char *cfgfile,
116 115
117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c); 116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c);
118 } 117 }
119
120 for (c = 0; c < rd_count; c++)
121 GNUNET_free ((void *) src[c].data);
122 GNUNET_NAMESTORE_records_free (dst_elem, dst);
123 GNUNET_free (rd_ser);
124} 118}
125 119
126static int 120static int