Skip to content

Commit

Permalink
Zephyr: Track memory allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Dec 2, 2024
1 parent 9b0ec2d commit 3457c2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions examples/zephyr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ZEPHYR_PROJECT?=~/zephyrproject
all: coap-client

coap-client: client-src/src/main.c client-src/*
LIBCOAP_DIR=`pwd`/../.. ;\
@LIBCOAP_DIR=`pwd`/../.. ;\
(. $(ZEPHYR_PROJECT)/.venv/bin/activate ;\
cd $(ZEPHYR_PROJECT)/zephyr ;\
west build -p always -b native_sim \
Expand All @@ -12,5 +12,9 @@ coap-client: client-src/src/main.c client-src/*
-DEXTRA_ZEPHYR_MODULES=$${LIBCOAP_DIR} \
-DEXTRA_CONF_FILE=$${LIBCOAP_DIR}/zephyr/libcoap-mbedtls.conf \
--fresh ;\
deactivate) ;\
cp -f $(ZEPHYR_PROJECT)/zephyr/build/zephyr/zephyr.exe coap-client
deactivate)
@cp -f $(ZEPHYR_PROJECT)/zephyr/build/zephyr/zephyr.exe coap-client

clean:
@rm -rf $(ZEPHYR_PROJECT)/zephyr/build
@rm -f coap-client
2 changes: 1 addition & 1 deletion examples/zephyr/client-src/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,5 @@ int main(void)
coap_free_context(coap_context);

coap_cleanup();
return 0;
exit(0);
}
2 changes: 2 additions & 0 deletions src/coap_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
#define mbedtls_realloc(a,b) realloc(a,b)
#define mbedtls_strdup(a) strdup(a)
#define mbedtls_strndup(a,b) strndup(a,b)
#undef mbedtls_free
#define mbedtls_free(a) free(a)

#ifndef MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
/* definition changed in later mbedtls code versions */
Expand Down
1 change: 1 addition & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if(CONFIG_LIBCOAP)

add_subdirectory(.. build)
target_compile_definitions(coap-3 PUBLIC WITH_ZEPHYR)
target_compile_definitions(coap-3 PUBLIC COAP_MEMORY_TYPE_TRACK=1)
target_link_libraries(coap-3 PUBLIC zephyr_interface)
set_property(GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS coap-3)

Expand Down

0 comments on commit 3457c2e

Please sign in to comment.