libcoap  4.1.2
str.h
Go to the documentation of this file.
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 
26 str *coap_new_string(size_t size);
27 
31 void coap_delete_string(str *);
32 
33 #endif /* _COAP_STR_H_ */
str * coap_new_string(size_t size)
Returns a new string object with at least size bytes storage allocated.
Definition: str.c:17
size_t length
Definition: str.h:16
void coap_delete_string(str *)
Deletes the given string and releases any memory allocated.
Definition: str.c:31
Definition: str.h:15
unsigned char * s
Definition: str.h:17