X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fidentity-attribute%2Fidentity_attribute.c;h=dc2753fcab9c5a88113f585ff8711fdbbbc6c102;hb=f40acfa927bb605c81c99ed250277d51bf951e25;hp=cf50d058e364a334dfb4bbe2f9e09862917925e6;hpb=056ca89d207cd1865a90fe3fcd430a4381097da5;p=oweals%2Fgnunet.git diff --git a/src/identity-attribute/identity_attribute.c b/src/identity-attribute/identity_attribute.c index cf50d058e..dc2753fca 100644 --- a/src/identity-attribute/identity_attribute.c +++ b/src/identity-attribute/identity_attribute.c @@ -240,6 +240,34 @@ GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name, return attr; } +/** + * Add a new claim list entry. + * + * @param claim_list the attribute name + * @param attr_name the attribute name + * @param type the attribute type + * @param data the attribute value + * @param data_size the attribute value size + * @return + */ +void +GNUNET_IDENTITY_ATTRIBUTE_list_add (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *claim_list, + const char* attr_name, + uint32_t type, + const void* data, + size_t data_size) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; + le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); + le->claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name, + type, + data, + data_size); + GNUNET_CONTAINER_DLL_insert (claim_list->list_head, + claim_list->list_tail, + le); +} + size_t GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) { @@ -308,18 +336,15 @@ GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *result_le; struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *result; - size_t len; result = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); for (le = attrs->list_head; NULL != le; le = le->next) { result_le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); - len = sizeof (struct GNUNET_IDENTITY_ATTRIBUTE_Claim) + le->claim->data_size; - result_le->claim = GNUNET_malloc (len); - GNUNET_memcpy (result_le->claim, - le->claim, - len); - result_le->claim->name = (const char*)&result_le->claim[1]; + result_le->claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (le->claim->name, + le->claim->type, + le->claim->data, + le->claim->data_size); GNUNET_CONTAINER_DLL_insert (result->list_head, result->list_tail, result_le);