From 9821b4b689cf06606cda0553c6ef4dcb5e0acac0 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sat, 10 Mar 2018 17:50:19 +0000 Subject: [PATCH] str.c: Replace str with coap_string_t At some point, str will get replaced in all of the code with coap_string_t. This is to prevent potential name clashes when compiling application code. Use coap_malloc_type(COAP_STRING,... instead of coap_malloc(... --- src/str.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/str.c b/src/str.c index 2c535e36..0f2feec6 100644 --- a/src/str.c +++ b/src/str.c @@ -15,8 +15,9 @@ #include "mem.h" #include "str.h" -str *coap_new_string(size_t size) { - str *s = (str *)coap_malloc(sizeof(str) + size + 1); +coap_string_t *coap_new_string(size_t size) { + coap_string_t *s = + (coap_string_t *)coap_malloc_type(COAP_STRING, sizeof(coap_string_t) + size + 1); if ( !s ) { #ifndef NDEBUG coap_log(LOG_CRIT, "coap_new_string: malloc\n"); @@ -24,12 +25,12 @@ str *coap_new_string(size_t size) { return NULL; } - memset(s, 0, sizeof(str)); - s->s = ((unsigned char *)s) + sizeof(str); + memset(s, 0, sizeof(coap_string_t)); + s->s = ((unsigned char *)s) + sizeof(coap_string_t); return s; } -void coap_delete_string(str *s) { - coap_free(s); +void coap_delete_string(coap_string_t *s) { + coap_free_type(COAP_STRING, s); }