1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 // The purpose of this module is to allow custom dynamic memory allocation
25 // code to easily be added to the TB Stack by redefining the OCMalloc and
26 // OCFree functions. Examples of when this might be needed are on TB
27 // platforms that do not support dynamic allocation or if a memory pool
30 // Note that these functions are intended to be used ONLY within the TB
31 // stack and NOT by the application code. The application should be
32 // responsible for its own dynamic allocation.
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
53 //-----------------------------------------------------------------------------
54 // Function prototypes
55 //-----------------------------------------------------------------------------
58 * Allocates a block of size bytes, returning a pointer to the beginning of
59 * the allocated block.
61 * @param size - Size of the memory block in bytes, where size > 0
64 * on success, a pointer to the allocated memory block
65 * on failure, a null pointer is returned
67 void *OCMalloc(size_t size);
70 * Allocates a block of memory for an array of num elements, each of them
71 * size bytes long and initializes all its bits to zero.
73 * @param num - The number of elements
74 * @param size - Size of the element type in bytes, where size > 0
77 * on success, a pointer to the allocated memory block
78 * on failure, a null pointer is returned
80 void *OCCalloc(size_t num, size_t size);
83 * Deallocate a block of memory previously allocated by a call to OCMalloc
85 * @param ptr - Pointer to block of memory previously allocated by OCMalloc.
86 * If ptr is a null pointer, the function does nothing.
88 void OCFree(void *ptr);
94 #endif /* OCMALLOC_H_ */