1 /*
2  * str.h -- strings to be used in the CoAP library
3  *
4  * Copyright (C) 2010-2011 Olaf Bergmann <bergmann@tzi.org>
5  *
6  * This file is part of the CoAP library libcoap. Please see README for terms
7  * of use.
8  */
9 
10 #ifndef _COAP_STR_H_
11 #define _COAP_STR_H_
12 
13 #include <string.h>
14 
15 typedef struct {
16   size_t length;    /* length of string */
17   unsigned char *s; /* string data */
18 } str;
19 
20 #define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
21 
22 /**
23  * Returns a new string object with at least size bytes storage allocated. The
24  * string must be released using coap_delete_string();
25  */
26 str *coap_new_string(size_t size);
27 
28 /**
29  * Deletes the given string and releases any memory allocated.
30  */
31 void coap_delete_string(str *);
32 
33 #endif /* _COAP_STR_H_ */
34