FS-9775: Added salloc call to dht for stack allocation, passing on the pool

This will be replicated to other allocations
This commit is contained in:
Shane Bryldt 2016-11-30 06:27:14 +00:00 committed by Mike Jerris
parent d0791961c4
commit 63d0d8dc4a
3 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,20 @@ KS_DECLARE(ks_status_t) ks_dht2_alloc(ks_dht2_t **dht, ks_pool_t *pool)
return KS_STATUS_SUCCESS;
}
/**
*
*/
KS_DECLARE(ks_status_t) ks_dht2_salloc(ks_dht2_t *dht, ks_pool_t *pool)
{
ks_assert(dht);
ks_assert(pool);
dht->pool = pool;
dht->pool_alloc = KS_FALSE;
return KS_STATUS_SUCCESS;
}
/**
*
*/
@ -45,6 +59,7 @@ KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht)
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const uint8_t *nodeid)
{
ks_assert(dht);
ks_assert(dht->pool);
if (ks_dht2_nodeid_init(&dht->nodeid, nodeid) != KS_STATUS_SUCCESS) {
return KS_STATUS_FAIL;

View File

@ -35,6 +35,7 @@ struct ks_dht2_s {
KS_DECLARE(ks_status_t) ks_dht2_alloc(ks_dht2_t **dht, ks_pool_t *pool);
KS_DECLARE(ks_status_t) ks_dht2_salloc(ks_dht2_t *dht, ks_pool_t *pool);
KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht);

View File

@ -36,7 +36,6 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid)
KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint8_t *id)
{
ks_assert(nodeid);
ks_assert(id);
if (!id) {
randombytes_buf(nodeid->id, KS_DHT_NODEID_LENGTH);