From 9b62b79ef766c06227585ed35bab6b64f44e1d43 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Mon, 16 Apr 2018 11:32:14 +0200 Subject: [PATCH] mem.c: allow re-definition of COAP_MAX_STRING_SIZE and COAP_MAX_STRINGS The pre-processor symbols COAP_MAX_STRING_SIZE and COAP_MAX_STRINGS are to be used on platforms that allocate memory from fixed-size blocks such as the MEMB allocator on Contiki. As the strings are used to reassemble URIs (including query strings), the reasonable string size depends on the application. The current values now are COAP_MAX_STRING_SIZE = 64, and COAP_MAX_STRINGS = 8. These can be changed at build time with compiler flag -D. Currently, only platform Contiki uses these definitions. --- src/mem.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mem.c b/src/mem.c index a3880659..4d056f4a 100644 --- a/src/mem.c +++ b/src/mem.c @@ -47,8 +47,21 @@ coap_free_type(coap_memory_tag_t type, void *p) { #ifdef WITH_CONTIKI -#define COAP_MAX_STRING_SIZE 12 +/** + * The maximum size of a string on platforms that allocate fixed-size + * memory blocks. + */ +#ifndef COAP_MAX_STRING_SIZE +#define COAP_MAX_STRING_SIZE 64 +#endif /* COAP_MAX_STRING_SIZE */ + +/** + * The maximum number of a strings on platforms that allocate + * fixed-size memory blocks. + */ +#ifndef COAP_MAX_STRINGS #define COAP_MAX_STRINGS 8 +#endif /* COAP_MAX_STRINGS */ struct coap_string_t { char data[COAP_MAX_STRING_SIZE];