diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-14 00:31:02 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-14 00:31:02 +0100 |
commit | 8d71f909cb22fbf6774e4042309a8eb133af3bfc (patch) | |
tree | 0efc19ac24a6521f927772364f1379154d2d0cad /src/peerstore/peerstore_common.c | |
parent | 6e01dc4d91d072e8e58ba0140fb7f4ddd5109358 (diff) | |
download | gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.tar.gz gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.zip |
convert sqlite peerstore to using libgnunetsq
Diffstat (limited to 'src/peerstore/peerstore_common.c')
-rw-r--r-- | src/peerstore/peerstore_common.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c index d12c4e21e..e0ab778fa 100644 --- a/src/peerstore/peerstore_common.c +++ b/src/peerstore/peerstore_common.c | |||
@@ -77,7 +77,7 @@ PEERSTORE_create_record_mq_envelope (const char *sub_system, | |||
77 | const char *key, | 77 | const char *key, |
78 | const void *value, | 78 | const void *value, |
79 | size_t value_size, | 79 | size_t value_size, |
80 | struct GNUNET_TIME_Absolute *expiry, | 80 | struct GNUNET_TIME_Absolute expiry, |
81 | enum GNUNET_PEERSTORE_StoreOption options, | 81 | enum GNUNET_PEERSTORE_StoreOption options, |
82 | uint16_t msg_type) | 82 | uint16_t msg_type) |
83 | { | 83 | { |
@@ -97,8 +97,7 @@ PEERSTORE_create_record_mq_envelope (const char *sub_system, | |||
97 | msg_size = ss_size + key_size + value_size; | 97 | msg_size = ss_size + key_size + value_size; |
98 | ev = GNUNET_MQ_msg_extra (srm, msg_size, msg_type); | 98 | ev = GNUNET_MQ_msg_extra (srm, msg_size, msg_type); |
99 | srm->key_size = htons (key_size); | 99 | srm->key_size = htons (key_size); |
100 | if (NULL != expiry) | 100 | srm->expiry = GNUNET_TIME_absolute_hton (expiry); |
101 | srm->expiry = *expiry; | ||
102 | if (NULL == peer) | 101 | if (NULL == peer) |
103 | srm->peer_set = htons (GNUNET_NO); | 102 | srm->peer_set = htons (GNUNET_NO); |
104 | else | 103 | else |
@@ -147,12 +146,9 @@ PEERSTORE_parse_record_message (const struct StoreRecordMessage *srm) | |||
147 | record = GNUNET_new (struct GNUNET_PEERSTORE_Record); | 146 | record = GNUNET_new (struct GNUNET_PEERSTORE_Record); |
148 | if (GNUNET_YES == ntohs (srm->peer_set)) | 147 | if (GNUNET_YES == ntohs (srm->peer_set)) |
149 | { | 148 | { |
150 | record->peer = GNUNET_new (struct GNUNET_PeerIdentity); | 149 | record->peer = srm->peer; |
151 | *record->peer = srm->peer; | ||
152 | } | 150 | } |
153 | record->expiry = GNUNET_new (struct GNUNET_TIME_Absolute); | 151 | record->expiry = GNUNET_TIME_absolute_ntoh (srm->expiry); |
154 | |||
155 | *(record->expiry) = srm->expiry; | ||
156 | dummy = (char *) &srm[1]; | 152 | dummy = (char *) &srm[1]; |
157 | if (ss_size > 0) | 153 | if (ss_size > 0) |
158 | { | 154 | { |
@@ -167,7 +163,9 @@ PEERSTORE_parse_record_message (const struct StoreRecordMessage *srm) | |||
167 | if (value_size > 0) | 163 | if (value_size > 0) |
168 | { | 164 | { |
169 | record->value = GNUNET_malloc (value_size); | 165 | record->value = GNUNET_malloc (value_size); |
170 | GNUNET_memcpy (record->value, dummy, value_size); | 166 | GNUNET_memcpy (record->value, |
167 | dummy, | ||
168 | value_size); | ||
171 | } | 169 | } |
172 | record->value_size = value_size; | 170 | record->value_size = value_size; |
173 | return record; | 171 | return record; |
@@ -184,8 +182,6 @@ PEERSTORE_destroy_record (struct GNUNET_PEERSTORE_Record *record) | |||
184 | { | 182 | { |
185 | if (NULL != record->sub_system) | 183 | if (NULL != record->sub_system) |
186 | GNUNET_free (record->sub_system); | 184 | GNUNET_free (record->sub_system); |
187 | if (NULL != record->peer) | ||
188 | GNUNET_free (record->peer); | ||
189 | if (NULL != record->key) | 185 | if (NULL != record->key) |
190 | GNUNET_free (record->key); | 186 | GNUNET_free (record->key); |
191 | if (NULL != record->value) | 187 | if (NULL != record->value) |
@@ -193,7 +189,5 @@ PEERSTORE_destroy_record (struct GNUNET_PEERSTORE_Record *record) | |||
193 | GNUNET_free (record->value); | 189 | GNUNET_free (record->value); |
194 | record->value = 0; | 190 | record->value = 0; |
195 | } | 191 | } |
196 | if (NULL != record->expiry) | ||
197 | GNUNET_free (record->expiry); | ||
198 | GNUNET_free (record); | 192 | GNUNET_free (record); |
199 | } | 193 | } |