Commit 6ebc1960 authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Johan Hedberg
Browse files

net: sockets: getaddrinfo: use k_ variants for memory allocation



The rest of the network (and generally Zephyr subsystem code) use the k_
prefixed variants for memory allocation, which results in data goin in
the _system_heap rather than the stdlib z_malloc_heap.

The code in getaddrinfo use the z_ ones as well apart from the actual
getaddrinfo implementation, which seems like an oversight, change it to
use k_calloc and k_free as well.

Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent 13bdae0a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -440,7 +440,7 @@ int zsock_getaddrinfo(const char *host, const char *service,
	int ret = DNS_EAI_FAIL;

#if defined(ANY_RESOLVER)
	*res = calloc(AI_ARR_MAX, sizeof(struct zsock_addrinfo));
	*res = k_calloc(AI_ARR_MAX, sizeof(struct zsock_addrinfo));
	if (!(*res)) {
		return DNS_EAI_MEMORY;
	}
@@ -461,7 +461,7 @@ int zsock_getaddrinfo(const char *host, const char *service,

#if defined(ANY_RESOLVER)
	if (ret) {
		free(*res);
		k_free(*res);
		*res = NULL;
	}
#endif
@@ -476,7 +476,7 @@ void zsock_freeaddrinfo(struct zsock_addrinfo *ai)
		return;
	}

	free(ai);
	k_free(ai);
}

#define ERR(e) case DNS_ ## e: return #e
+1 −0
Original line number Diff line number Diff line
@@ -27,3 +27,4 @@ CONFIG_PRINTK=y
CONFIG_ZTEST=y

CONFIG_MAIN_STACK_SIZE=1344
CONFIG_HEAP_MEM_POOL_SIZE=1024
+1 −0
Original line number Diff line number Diff line
@@ -29,5 +29,6 @@ CONFIG_PRINTK=y
CONFIG_ZTEST=y

CONFIG_MAIN_STACK_SIZE=1344
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_ZVFS_OPEN_MAX=9
CONFIG_ZVFS_POLL_MAX=9
+1 −0
Original line number Diff line number Diff line
@@ -13,3 +13,4 @@ CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_MLD=n
CONFIG_NET_IF_MAX_IPV4_COUNT=4
CONFIG_NET_IF_MAX_IPV6_COUNT=4
CONFIG_HEAP_MEM_POOL_SIZE=512
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ CONFIG_ZTEST=y

# User mode requirements
CONFIG_TEST_USERSPACE=y
CONFIG_HEAP_MEM_POOL_SIZE=128
CONFIG_HEAP_MEM_POOL_SIZE=512

# We do not need neighbor discovery etc for this test
CONFIG_NET_IPV6_DAD=n