keith-cullen / FreeCoAP

An implementation of a CoAP client, a CoAP server and a HTTP/CoAP proxy with full DTLS support.
132 stars 38 forks source link

question about coap_mem / samples #33

Closed smufu closed 2 years ago

smufu commented 3 years ago

Hi, should I use coap_mem in user code? I saw that make install will not include coap_mem.h, but the samples use it (transfer_server). Also the symbols used by coap_mem are not exported.

Do I have to use coap_mem_all_create / coap_mem_all_destory and if so how?

lib/Makefile:336
  include_HEADERS = include/coap_msg.h include/coap_log.h include/coap_client.h include/coap_server.h include/coap_ipv.h
When I copy the header over:
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_small_alloc'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_medium_get_len'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_large_get_len'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_small_get_len'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_small_free'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_medium_alloc'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_large_alloc'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_large_free'
/usr/bin/ld: /home/smufu/.local/lib/libfreecoap.so: undefined reference to `coap_mem_medium_free'
keith-cullen commented 3 years ago

This was a bug. It has been fixed now. Autotools should work for you. You can use coap_mem in user code. It is a slab allocator so that malloc is called on start-up and then is never called at run-time. This makes the code faster and more deterministic. You may want to increase the memory pool when coap_mem_all_create is called to allow for the extra memory your application will use.