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.
This commit is contained in:
Olaf Bergmann committed 2018-04-16 11:32:14 +02:00
1 parent 132a830b59
commit 9b62b79ef7
1 file changed
+14 -1
+14 -1
View File
@@ -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];