1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* mem.h -- CoAP memory handling
*
* Copyright (C) 2010-2011,2014-2015 Olaf Bergmann <bergmann@tzi.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
/**
* @file mem.h
* @brief CoAP memory handling
*/
/**
* Initializes libcoap's memory management.
* This function must be called once before coap_malloc() can be used on
* constrained devices.
*/
void ;
/* WITH_LWIP */
/**
* Type specifiers for coap_malloc_type(). Memory objects can be typed to
* facilitate arrays of type objects to be used instead of dynamic memory
* management on constrained devices.
*/
typedef enum coap_memory_tag_t;
/**
* Allocates a chunk of @p size bytes and returns a pointer to the newly
* allocated memory. The @p type is used to select the appropriate storage
* container on constrained devices. The storage allocated by coap_malloc_type()
* must be released with coap_free_type().
*
* @param type The type of object to be stored.
* @param size The number of bytes requested.
* @return A pointer to the allocated storage or @c NULL on error.
*/
void *;
/**
* Reallocates a chunk @p p of bytes created by coap_malloc_type() or
* coap_realloc_type() and returns a pointer to the newly allocated memory of
* @p size.
* Only COAP_STRING type is supported.
*
* Note: If there is an error, @p p will separately need to be released by
* coap_free_type().
*
* @param type The type of object to be stored.
* @param p A pointer to memory that was allocated by coap_malloc_type().
* @param size The number of bytes requested.
* @return A pointer to the allocated storage or @c NULL on error.
*/
void *;
/**
* Releases the memory that was allocated by coap_malloc_type(). The type tag @p
* type must be the same that was used for allocating the object pointed to by
* @p .
*
* @param type The type of the object to release.
* @param p A pointer to memory that was allocated by coap_malloc_type().
*/
void ;
/**
* Wrapper function to coap_malloc_type() for backwards compatibility.
*/
COAP_STATIC_INLINE void *
/**
* Wrapper function to coap_free_type() for backwards compatibility.
*/
COAP_STATIC_INLINE void
/* not WITH_LWIP */
/* no initialization needed with lwip (or, more precisely: lwip must be
* completely initialized anyway by the time coap gets active) */
COAP_STATIC_INLINE void
/* It would be nice to check that size equals the size given at the memp
* declaration, but i currently don't see a standard way to check that without
* sourcing the custom memp pools and becoming dependent of its syntax
*/
/* Those are just here to make uri.c happy where string allocation has not been
* made conditional.
*/
COAP_STATIC_INLINE void *
COAP_STATIC_INLINE void
/* WITH_LWIP */
/* COAP_MEM_H_ */