| 1 |
/* |
| 2 |
* FCML - Free Code Manipulation Library. |
| 3 |
* Copyright (C) 2010-2020 Slawomir Wojtasiak |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
/** @file fcml_env.h |
| 21 |
* API for environment configuration. |
| 22 |
* @copyright Copyright (C) 2010-2020 Slawomir Wojtasiak. All rights reserved. |
| 23 |
* This project is released under the GNU Lesser General Public License. |
| 24 |
*/ |
| 25 |
|
| 26 |
#ifndef FCML_ENV_H_ |
| 27 |
#define FCML_ENV_H_ |
| 28 |
|
| 29 |
#include "fcml_types.h" |
| 30 |
|
| 31 |
#ifdef __cplusplus |
| 32 |
extern "C" { |
| 33 |
#endif |
| 34 |
|
| 35 |
/** Memory allocator handler function pointer declaration. |
| 36 |
* Memory allocation handlers are used to allocate requested memory in |
| 37 |
* environment specific way. |
| 38 |
* @param size Size of the memory to allocate. |
| 39 |
* @return The allocated memory block or NULL in case of out of memory. |
| 40 |
*/ |
| 41 |
typedef fcml_ptr (*fcml_fp_env_memory_alloc_handler)(fcml_usize size); |
| 42 |
|
| 43 |
/** Memory reallocator handler function pointer declaration. |
| 44 |
* Memory reallocation handlers are used to reallocate requested memory in |
| 45 |
* environment specific way. |
| 46 |
* @param ptr The memory block to be reallocated. |
| 47 |
* @param size Size of the memory to allocate. |
| 48 |
* @return The reallocated memory block or NULL in case of out of memory. |
| 49 |
*/ |
| 50 |
typedef fcml_ptr (*fcml_fp_env_memory_realloc_handler)(fcml_ptr ptr, |
| 51 |
fcml_usize size); |
| 52 |
|
| 53 |
/** Memory deallocator handler function pointer declaration. |
| 54 |
* Memory deallocation handlers are used to free requested memory blocks in |
| 55 |
* environment specific way. |
| 56 |
* @param memory_block The memory block to free. |
| 57 |
*/ |
| 58 |
typedef void (*fcml_fp_env_memory_free_handler)(fcml_ptr memory_block); |
| 59 |
|
| 60 |
/** |
| 61 |
* Registers the new dedicated handler responsible for allocating |
| 62 |
* memory for the sake of internal FCML implementation. |
| 63 |
* @param handler New memory allocation handler. |
| 64 |
* @return The replaced memory handler. |
| 65 |
*/ |
| 66 |
LIB_EXPORT fcml_fp_env_memory_alloc_handler LIB_CALL |
| 67 |
fcml_fn_env_register_memory_alloc_handler( |
| 68 |
fcml_fp_env_memory_alloc_handler handler); |
| 69 |
|
| 70 |
/** |
| 71 |
* Registers the new dedicated handler responsible for reallocating |
| 72 |
* memory for the sake |
| 73 |
* of internal FCML implementation. |
| 74 |
* @param handler New memory reallocation handler. |
| 75 |
* @return The replaced memory handler. |
| 76 |
*/ |
| 77 |
LIB_EXPORT fcml_fp_env_memory_realloc_handler LIB_CALL |
| 78 |
fcml_fn_env_register_memory_realloc_handler( |
| 79 |
fcml_fp_env_memory_realloc_handler handler); |
| 80 |
|
| 81 |
/** |
| 82 |
* Registers the new dedicated handler responsible for deallocating the |
| 83 |
* memory for the sake |
| 84 |
* of internal FCML implementation. |
| 85 |
* @param handler New memory deallocation handler. |
| 86 |
* @return The replaced memory handler. |
| 87 |
*/ |
| 88 |
LIB_EXPORT fcml_fp_env_memory_free_handler LIB_CALL |
| 89 |
fcml_fn_env_register_memory_free_handler( |
| 90 |
fcml_fp_env_memory_free_handler handler); |
| 91 |
|
| 92 |
#ifdef __cplusplus |
| 93 |
} |
| 94 |
#endif |
| 95 |
|
| 96 |
#endif /* FCML_ENV_H_ */ |