Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/utils/os_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ int clock_gettime(clockid_t clock_id, struct timespec *ts);
#include "includes.h"
#include "os.h"

#if !defined(CONFIG_WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP)
K_HEAP_DEFINE(wifi_nm_wpa_supplicant_mem_pool, CONFIG_WIFI_NM_WPA_SUPPLICANT_HEAP);
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP */

void os_sleep(os_time_t sec, os_time_t usec)
{
k_sleep(K_USEC(usec + USEC_PER_SEC * sec));
Expand Down Expand Up @@ -220,12 +224,22 @@ void *os_memdup(const void *src, size_t len)

void *os_malloc(size_t size)
{
#if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP)
return k_malloc(size);
#else
return sys_heap_noalign_alloc(&wifi_nm_wpa_supplicant_mem_pool.heap, 0, size);
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP */
}

void os_free(void *ptr)
{
k_free(ptr);
if (ptr) {
#if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP)
k_free(ptr);
#else
k_heap_free(&wifi_nm_wpa_supplicant_mem_pool, ptr);
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP */
}
}

void *os_realloc(void *ptr, size_t newsize)
Expand Down Expand Up @@ -255,7 +269,7 @@ void *os_realloc(void *ptr, size_t newsize)

void *os_zalloc(size_t size)
{
void *p = k_malloc(size);
void *p = os_malloc(size);

if (p != NULL) {
(void)memset(p, 0, size);
Expand Down