diff options
author | Angelo Mantellini <manangel@cisco.com> | 2019-02-05 08:50:26 +0100 |
---|---|---|
committer | Angelo Mantellini <manangel@cisco.com> | 2019-02-06 16:23:04 +0100 |
commit | 9f68541e0f55495d61dd9e583bec38740a247597 (patch) | |
tree | 55519e34159ac1eb691e080e4c1eab5b0e4847bd /libparc/parc/algol/parc_Memory.h | |
parent | b77148ddc3def71e6c412c3afb5f1c20be2d77cd (diff) |
[HICN-26] Windows compatibilty for libparc
Change-Id: I6ebff82a81a2bf42fa3bf210ff0e6e530ce21915
Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'libparc/parc/algol/parc_Memory.h')
-rw-r--r-- | libparc/parc/algol/parc_Memory.h | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/libparc/parc/algol/parc_Memory.h b/libparc/parc/algol/parc_Memory.h index fe3c4b5a..6e4a84e8 100644 --- a/libparc/parc/algol/parc_Memory.h +++ b/libparc/parc/algol/parc_Memory.h @@ -43,6 +43,10 @@ typedef int (PARCMemoryMemAlign)(void **pointer, size_t alignment, size_t size); typedef void (PARCMemoryDeallocate)(void **pointer); +#ifdef _WIN32 +typedef void (PARCMemoryDeallocateAlign)(void **pointer); +#endif + typedef void *(PARCMemoryReallocate)(void *pointer, size_t newSize); typedef char *(PARCMemoryStringDuplicate)(const char *string, size_t length); @@ -121,6 +125,19 @@ typedef struct parc_memory_interface { */ uintptr_t Deallocate; +#ifdef _WIN32 + /** + * Deallocate memory previously Aligned allocated via `MemAlign`. + * + * @param [in,out] pointer A pointer to a `void *` pointer to the address of the allocated memory that will be set to zero. + * + * @see AllocateAndClear + * @see Allocate + * @see Reallocate + */ + uintptr_t DeallocateAlign; +#endif + /** * Try to change the size of the allocation pointed to by @p pointer to @p newSize, and returns ptr. * If there is not enough room to enlarge the memory allocation pointed to by @p pointer, @@ -308,8 +325,35 @@ int parcMemory_MemAlign(void **pointer, const size_t alignment, const size_t siz */ void parcMemory_DeallocateImpl(void **pointer); +#ifdef _WIN32 +/** + * Deallocate memory previously allocated via `MemAlign`. + * + * @param [in,out] pointer A pointer to a `void *` pointer to the address of the allocated memory that will be set to zero. + * + * Example: + * @code + * { + * void *allocatedMemory; + * + * allocatedMemory = parcMemory_Allocate(100); + * if (allocatedMemory == NULL) { + * // allocation failed + * } + * } + * @endcode + * + * @see parcMemory_MemAlign + */ +void parcMemory_DeallocateAlignImpl(void **pointer); +#endif + #define parcMemory_Deallocate(_pointer_) parcMemory_DeallocateImpl((void **) _pointer_) +#ifdef _WIN32 +#define parcMemory_DeallocateAlign(_pointer_) parcMemory_DeallocateAlignImpl((void **) _pointer_) +#endif + /** * Try to change the size of the allocation pointed to by @p pointer to @p newSize, and returns ptr. * If there is not enough room to enlarge the memory allocation pointed to by @p pointer, @@ -432,7 +476,7 @@ size_t parcMemory_RoundUpToCacheLine(const size_t size); * * @see parcMemory_RoundUpToCacheLine */ -size_t parcMemory_RoundUpToMultiple(size_t size, size_t multiple); +size_t parcMemory_RoundUpToMultiple(const size_t size, const size_t multiple); /** * @def parcMemory_SafeFree |