memory: Support debug tracking of memory usage

New function coap_dump_memory_type_counts().

Requires COAP_MEMORY_TYPE_TRACK to be defined as 1.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2023-10-24 12:43:13 +01:00
1 parent 7688258c39
commit 17e44c73df
5 files changed
+161 -8

No files matched your search

+12
View File
@@ -64,6 +64,7 @@ typedef enum {
COAP_OSCORE_EP,
COAP_OSCORE_BUF,
COAP_COSE,
COAP_MEM_TAG_LAST
} coap_memory_tag_t;
#ifndef WITH_LWIP
@@ -106,6 +107,15 @@ void *coap_realloc_type(coap_memory_tag_t type, void *p, size_t size);
*/
void coap_free_type(coap_memory_tag_t type, void *p);
/**
* Dumps the current usage of malloc'd memory types.
*
* Requires COAP_MEMORY_TYPE_TRACK to be defined to 1.
*
* @param log_level The logging level to use.
*/
void coap_dump_memory_type_counts(coap_log_t log_level);
/**
* Wrapper function to coap_malloc_type() for backwards compatibility.
*/
@@ -161,6 +171,8 @@ coap_free(void *pointer) {
LWIP_ASSERT("coap_free must not be used in lwIP", 0);
}
#define coap_dump_memory_type_counts(l) coap_lwip_dump_memory_pools(l)
#endif /* WITH_LWIP */
#endif /* COAP_MEM_H_ */