embeddedartistry / libmemory

Embedded systems memory management library. Implementations for malloc(), free(), and other useful memory management functions
https://embeddedartistry.com
MIT License
216 stars 44 forks source link

Add a build option that can be used to override the free list static declaration #86

Closed phillipjohnston closed 2 years ago

phillipjohnston commented 2 years ago

Fixes #84

Example Output from a manual test case

Default, with a test case that tries to access the list in another file:

[2/2] Linking target test/libmemory_freelist_test
FAILED: test/libmemory_freelist_test
cc  -o test/libmemory_freelist_test test/libmemory_freelist_test.p/main.c.o test/libmemory_freelist_test.p/support_memory.c.o test/libmemory_freelist_test.p/src_aligned_malloc.c.o test/libmemory_freelist_test.p/src_malloc_freelist.c.o -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error -Wl,-rpath,@loader_path/../subprojects/cmocka-1.1.5/src subprojects/cmocka-1.1.5/src/libcmocka_native.0.dylib src/libmemory_freelist_native.a
Undefined symbols for architecture x86_64:
  "_free_list", referenced from:
      _malloc_test in src_malloc_freelist.c.o

After $ make OPTIONS=-Dfreelist-declared-static=false, the application will link successfully and we can iterate over the free list.

phillipjohnston commented 2 years ago

cc @stefanct