libcoap
4.1.1
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Groups
Pages
str.c
Go to the documentation of this file.
1
/* str.c -- strings to be used in the CoAP library
2
*
3
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
4
*
5
* This file is part of the CoAP library libcoap. Please see
6
* README for terms of use.
7
*/
8
9
#include "
config.h
"
10
11
#include <stdio.h>
12
13
#include "
debug.h
"
14
#include "
mem.h
"
15
#include "
str.h
"
16
17
str
*
coap_new_string
(
size_t
size) {
18
str
*s =
coap_malloc
(
sizeof
(
str
) + size + 1);
19
if
( !s ) {
20
#ifndef NDEBUG
21
coap_log
(LOG_CRIT,
"coap_new_string: malloc\n"
);
22
#endif
23
return
NULL;
24
}
25
26
memset(s, 0,
sizeof
(
str
));
27
s->
s
= ((
unsigned
char
*)s) +
sizeof
(
str
);
28
return
s;
29
}
30
31
void
coap_delete_string
(
str
*s) {
32
coap_free
(s);
33
}
34
coap_new_string
str * coap_new_string(size_t size)
Returns a new string object with at least size bytes storage allocated.
Definition:
str.c:17
mem.h
debug.h
config.h
coap_malloc
#define coap_malloc(size)
Definition:
mem.h:15
str.h
coap_free
#define coap_free(size)
Definition:
mem.h:16
str
Definition:
str.h:14
coap_delete_string
void coap_delete_string(str *s)
Deletes the given string and releases any memory allocated.
Definition:
str.c:31
coap_log
#define coap_log(...)
Definition:
debug.h:47
str::s
unsigned char * s
Definition:
str.h:16
Generated on Thu May 7 2015 19:23:26 for libcoap by
1.8.6