]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9775: Added salloc calls for other entities
authorShane Bryldt <astaelan@gmail.com>
Wed, 30 Nov 2016 06:42:11 +0000 (06:42 +0000)
committerMike Jerris <mike@jerris.com>
Wed, 25 Jan 2017 20:59:33 +0000 (14:59 -0600)
The use of salloc in the main ks_dht_t for the inner nodeid suggests salloc calls
should be renamed prealloc to avoid confusion where not used on stack variables

libs/libks/src/dht/ks_dht.c
libs/libks/src/dht/ks_dht_endpoint-int.h
libs/libks/src/dht/ks_dht_endpoint.c
libs/libks/src/dht/ks_dht_nodeid.c
libs/libks/src/dht/ks_dht_nodeid.h

index e93c424ba061064d963b454b10f2728a27d98b41..1c9c7effe4a9fc38c0b35d9305718c9ec45cb689 100644 (file)
@@ -61,6 +61,10 @@ 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_salloc(&dht->nodeid, dht->pool) != KS_STATUS_SUCCESS) {
+               return KS_STATUS_FAIL;
+       }
+       
        if (ks_dht2_nodeid_init(&dht->nodeid, nodeid) != KS_STATUS_SUCCESS) {
                return KS_STATUS_FAIL;
        }
index c8361aca0b0ceab06034fa37632aa0456554d1db..8483a8a03800378eeee58f8be82c60667c818552 100644 (file)
@@ -6,6 +6,7 @@
 KS_BEGIN_EXTERN_C
 
 KS_DECLARE(ks_status_t) ks_dht2_endpoint_alloc(ks_dht2_endpoint_t **endpoint, ks_pool_t *pool);
+KS_DECLARE(ks_status_t) ks_dht2_endpoint_salloc(ks_dht2_endpoint_t *endpoint, ks_pool_t *pool);
 KS_DECLARE(ks_status_t) ks_dht2_endpoint_free(ks_dht2_endpoint_t *endpoint);
 
 KS_DECLARE(ks_status_t) ks_dht2_endpoint_init(ks_dht2_endpoint_t *endpoint, const ks_sockaddr_t *addr, ks_socket_t sock);
index 2818a7c98f567e93ad674dabbc2934f09f061af3..3b5d21b474b1ff869e4d37afbe6248adf6ec62f9 100644 (file)
@@ -17,6 +17,19 @@ KS_DECLARE(ks_status_t) ks_dht2_endpoint_alloc(ks_dht2_endpoint_t **endpoint, ks
        return KS_STATUS_SUCCESS;
 }
 
+/**
+ *
+ */
+KS_DECLARE(ks_status_t) ks_dht2_endpoint_salloc(ks_dht2_endpoint_t *endpoint, ks_pool_t *pool)
+{
+       ks_assert(endpoint);
+       ks_assert(pool);
+
+       endpoint->pool = pool;
+
+       return KS_STATUS_SUCCESS;
+}
+
 /**
  *
  */
@@ -28,7 +41,7 @@ KS_DECLARE(ks_status_t) ks_dht2_endpoint_free(ks_dht2_endpoint_t *endpoint)
 
        return KS_STATUS_SUCCESS;
 }
-                                                                                               
+
 
 /**
  *
@@ -36,6 +49,7 @@ KS_DECLARE(ks_status_t) ks_dht2_endpoint_free(ks_dht2_endpoint_t *endpoint)
 KS_DECLARE(ks_status_t) ks_dht2_endpoint_init(ks_dht2_endpoint_t *endpoint, const ks_sockaddr_t *addr, ks_socket_t sock)
 {
        ks_assert(endpoint);
+       ks_assert(endpoint->pool);
        ks_assert(addr);
        ks_assert(addr->family == AF_INET || addr->family == AF_INET6);
 
index 735213dce2f7f69aa41246ae0a5cccf3205988a1..a3a6296ec218a2fc8bb42af5fbdd41ed7edf16e1 100644 (file)
@@ -17,6 +17,19 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_alloc(ks_dht2_nodeid_t **nodeid, ks_pool_
        return KS_STATUS_SUCCESS;
 }
 
+/**
+ *
+ */
+KS_DECLARE(ks_status_t) ks_dht2_nodeid_salloc(ks_dht2_nodeid_t *nodeid, ks_pool_t *pool)
+{
+       ks_assert(nodeid);
+       ks_assert(pool);
+       
+       nodeid->pool = pool;
+
+       return KS_STATUS_SUCCESS;
+}
+
 /**
  *
  */
@@ -36,6 +49,7 @@ 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(nodeid->pool);
 
        if (!id) {
                randombytes_buf(nodeid->id, KS_DHT_NODEID_LENGTH);
index 5eef173b7c57a7cac32bbae94e02c5e534e333ad..d8b2594a2f3aa5aa38f326f74b025ad5a3455d5c 100644 (file)
@@ -14,6 +14,7 @@ struct ks_dht2_nodeid_s {
 };
 
 KS_DECLARE(ks_status_t) ks_dht2_nodeid_alloc(ks_dht2_nodeid_t **nodeid, ks_pool_t *pool);
+KS_DECLARE(ks_status_t) ks_dht2_nodeid_salloc(ks_dht2_nodeid_t *nodeid, ks_pool_t *pool);
 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);