* DLL
*/
struct CredentialRecordEntry *prev;
-
+
+ /**
+ * Number of references in delegation chains
+ */
+ uint32_t refcount;
/**
* Payload
struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size];
struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size];
struct CredentialRecordEntry *cd;
+ struct CredentialRecordEntry *tmp;
size_t size;
int i;
dce = dce->next;
}
+ /**
+ * Remove all credentials not needed
+ */
+ for (cd = vrh->cred_chain_head; NULL != cd;)
+ {
+ if (cd->refcount > 0)
+ {
+ cd = cd->next;
+ continue;
+ }
+ tmp = cd;
+ cd = cd->next;
+ GNUNET_CONTAINER_DLL_remove (vrh->cred_chain_head,
+ vrh->cred_chain_tail,
+ tmp);
+ GNUNET_free (tmp->credential);
+ GNUNET_free (tmp);
+ vrh->cred_chain_size--;
+ }
+
/**
* Get serialized record data
* Append at the end of rmsg
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found issuer\n");
-
+ cred_pointer->refcount++;
//Backtrack
for (tmp_set = ds_entry;
NULL != tmp_set->parent_queue_entry;
ds_entry->issuer_key, //issuer_key,
GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
GNUNET_GNS_LO_DEFAULT,
- NULL, //shorten_key, always NULL
&backward_resolution,
ds_entry);
GNUNET_free (lookup_attribute);
continue;
if (0 != strcmp (cr_entry->credential->issuer_attribute, vrh->issuer_attribute))
continue;
+ cr_entry->refcount++;
//Found match prematurely
send_lookup_response (vrh);
return;
&vrh->issuer_key, //issuer_key,
GNUNET_GNSRECORD_TYPE_ATTRIBUTE,
GNUNET_GNS_LO_DEFAULT,
- NULL, //shorten_key, always NULL
&backward_resolution,
ds_entry);
}
for (i=0;i<credentials_count;i++) {
cr_entry = GNUNET_new (struct CredentialRecordEntry);
cr_entry->credential = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Credential) +
- strlen (credentials[i].issuer_attribute) + 1);
+ credentials[i].issuer_attribute_len);
GNUNET_memcpy (cr_entry->credential,
&credentials[i],
sizeof (struct GNUNET_CREDENTIAL_Credential));
GNUNET_memcpy (&cr_entry->credential[1],
credentials[i].issuer_attribute,
- strlen (credentials[i].issuer_attribute));
+ credentials[i].issuer_attribute_len);
cr_entry->credential->issuer_attribute = (char*)&cr_entry->credential[1];
GNUNET_CONTAINER_DLL_insert_tail (vrh->cred_chain_head,
vrh->cred_chain_tail,