Files
libcoap/str.c
T
Olaf Bergmann 3358f2901d Fixed license info.
Options iterator.
Address abstraction to allow IPv4 addresses.
more changes for draft-ietf-core-coap-06.
2011-06-02 02:43:59 +02:00

30 lines
568 B
C

/* str.c -- strings to be used in the CoAP library
*
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see
* README for terms of use.
*/
#include <stdio.h>
#include "mem.h"
#include "str.h"
str *coap_new_string(size_t size) {
str *s = coap_malloc(sizeof(str) + size + 1);
if ( !s ) {
perror("coap_new_string: malloc");
return NULL;
}
memset(s, 0, sizeof(str));
s->s = ((unsigned char *)s) + sizeof(str);
return s;
}
void coap_delete_string(str *s) {
coap_free(s);
}