aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/peerstore_common.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-14 00:31:02 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-14 00:31:02 +0100
commit8d71f909cb22fbf6774e4042309a8eb133af3bfc (patch)
tree0efc19ac24a6521f927772364f1379154d2d0cad /src/peerstore/peerstore_common.c
parent6e01dc4d91d072e8e58ba0140fb7f4ddd5109358 (diff)
convert sqlite peerstore to using libgnunetsq
Diffstat (limited to 'src/peerstore/peerstore_common.c')
-rw-r--r--src/peerstore/peerstore_common.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c
index d12c4e21ee..e0ab778faf 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,
const char *key,
const void *value,
size_t value_size,
- struct GNUNET_TIME_Absolute *expiry,
+ struct GNUNET_TIME_Absolute expiry,
enum GNUNET_PEERSTORE_StoreOption options,
uint16_t msg_type)
{
@@ -97,8 +97,7 @@ PEERSTORE_create_record_mq_envelope (const char *sub_system,
msg_size = ss_size + key_size + value_size;
ev = GNUNET_MQ_msg_extra (srm, msg_size, msg_type);
srm->key_size = htons (key_size);
- if (NULL != expiry)
- srm->expiry = *expiry;
+ srm->expiry = GNUNET_TIME_absolute_hton (expiry);
if (NULL == peer)
srm->peer_set = htons (GNUNET_NO);
else
@@ -147,12 +146,9 @@ PEERSTORE_parse_record_message (const struct StoreRecordMessage *srm)
record = GNUNET_new (struct GNUNET_PEERSTORE_Record);
if (GNUNET_YES == ntohs (srm->peer_set))
{
- record->peer = GNUNET_new (struct GNUNET_PeerIdentity);
- *record->peer = srm->peer;
+ record->peer = srm->peer;
}
- record->expiry = GNUNET_new (struct GNUNET_TIME_Absolute);
-
- *(record->expiry) = srm->expiry;
+ record->expiry = GNUNET_TIME_absolute_ntoh (srm->expiry);
dummy = (char *) &srm[1];
if (ss_size > 0)
{
@@ -167,7 +163,9 @@ PEERSTORE_parse_record_message (const struct StoreRecordMessage *srm)
if (value_size > 0)
{
record->value = GNUNET_malloc (value_size);
- GNUNET_memcpy (record->value, dummy, value_size);
+ GNUNET_memcpy (record->value,
+ dummy,
+ value_size);
}
record->value_size = value_size;
return record;
@@ -184,8 +182,6 @@ PEERSTORE_destroy_record (struct GNUNET_PEERSTORE_Record *record)
{
if (NULL != record->sub_system)
GNUNET_free (record->sub_system);
- if (NULL != record->peer)
- GNUNET_free (record->peer);
if (NULL != record->key)
GNUNET_free (record->key);
if (NULL != record->value)
@@ -193,7 +189,5 @@ PEERSTORE_destroy_record (struct GNUNET_PEERSTORE_Record *record)
GNUNET_free (record->value);
record->value = 0;
}
- if (NULL != record->expiry)
- GNUNET_free (record->expiry);
GNUNET_free (record);
}