AWS IoT Device SDK C: Static Memory
Statically-allocated buffer pools
Return to main page ↑
iot_static_memory.h
Go to the documentation of this file.
1 /*
2  * IoT Common V1.1.0
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
29 #ifndef IOT_STATIC_MEMORY_H_
30 #define IOT_STATIC_MEMORY_H_
31 
32 /* The config header is always included first. */
33 #include "iot_config.h"
34 
35 /* The functions in this file should only exist in static memory only mode. */
36 #if ( IOT_STATIC_MEMORY_ONLY == 1 )
37 
38 
39 /* Standard includes. */
40  #include <stddef.h>
41  #include <stdint.h>
42 
52 /*------------------------- Buffer allocation and free ----------------------*/
53 
103 /* @[declare_static_memory_findfree] */
104  int32_t IotStaticMemory_FindFree( uint32_t * pInUse,
105  size_t limit );
106 /* @[declare_static_memory_findfree] */
107 
140 /* @[declare_static_memory_returninuse] */
141  void IotStaticMemory_ReturnInUse( void * ptr,
142  void * pPool,
143  uint32_t * pInUse,
144  size_t limit,
145  size_t elementSize );
146 /* @[declare_static_memory_returninuse] */
147 
148 /*------------------------ Message buffer management ------------------------*/
149 
165 /* @[declare_static_memory_messagebuffersize] */
166  size_t Iot_MessageBufferSize( void );
167 /* @[declare_static_memory_messagebuffersize] */
168 
182 /* @[declare_static_memory_mallocmessagebuffer] */
183  void * Iot_MallocMessageBuffer( size_t size );
184 /* @[declare_static_memory_mallocmessagebuffer] */
185 
195 /* @[declare_static_memory_freemessagebuffer] */
196  void Iot_FreeMessageBuffer( void * ptr );
197 /* @[declare_static_memory_freemessagebuffer] */
198 
199 #endif /* if ( IOT_STATIC_MEMORY_ONLY == 1 ) */
200 #endif /* ifndef IOT_STATIC_MEMORY_H_ */
void * Iot_MallocMessageBuffer(size_t size)
Get an empty message buffer.
Definition: iot_static_memory_common.c:140
int32_t IotStaticMemory_FindFree(uint32_t *pInUse, size_t limit)
Find a free buffer using the "in-use" flags.
Definition: iot_static_memory_common.c:83
void Iot_FreeMessageBuffer(void *ptr)
Free an in-use message buffer.
Definition: iot_static_memory_common.c:163
void IotStaticMemory_ReturnInUse(void *ptr, void *pPool, uint32_t *pInUse, size_t limit, size_t elementSize)
Return an "in-use" buffer.
Definition: iot_static_memory_common.c:103
size_t Iot_MessageBufferSize(void)
Get the fixed size of a message buffer.
Definition: iot_static_memory_common.c:133