sl@0: /* sl@0: ****************************************************************************** sl@0: * sl@0: * Copyright (C) 1997-2003, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ****************************************************************************** sl@0: * sl@0: * File CMEMORY.H sl@0: * sl@0: * Contains stdlib.h/string.h memory functions sl@0: * sl@0: * @author Bertrand A. Damiba sl@0: * sl@0: * Modification History: sl@0: * sl@0: * Date Name Description sl@0: * 6/20/98 Bertrand Created. sl@0: * 05/03/99 stephen Changed from functions to macros. sl@0: * sl@0: ****************************************************************************** sl@0: */ sl@0: sl@0: #ifndef CMEMORY_H sl@0: #define CMEMORY_H sl@0: sl@0: #include "unicode/utypes.h" sl@0: #include sl@0: sl@0: sl@0: #define uprv_memcpy(dst, src, size) U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size) sl@0: #define uprv_memmove(dst, src, size) U_STANDARD_CPP_NAMESPACE memmove(dst, src, size) sl@0: #define uprv_memset(buffer, mark, size) U_STANDARD_CPP_NAMESPACE memset(buffer, mark, size) sl@0: #define uprv_memcmp(buffer1, buffer2, size) U_STANDARD_CPP_NAMESPACE memcmp(buffer1, buffer2,size) sl@0: sl@0: U_CAPI void * U_EXPORT2 sl@0: uprv_malloc(size_t s); sl@0: sl@0: U_CAPI void * U_EXPORT2 sl@0: uprv_realloc(void *mem, size_t size); sl@0: sl@0: U_CAPI void U_EXPORT2 sl@0: uprv_free(void *mem); sl@0: sl@0: /** sl@0: * This should align the memory properly on any machine. sl@0: * This is very useful for the safeClone functions. sl@0: */ sl@0: typedef union { sl@0: long t1; sl@0: double t2; sl@0: void *t3; sl@0: } UAlignedMemory; sl@0: sl@0: /** sl@0: * Get the amount of bytes that a pointer is off by from sl@0: * the previous aligned pointer sl@0: */ sl@0: #define U_ALIGNMENT_OFFSET(ptr) (((size_t)ptr) & (sizeof(UAlignedMemory) - 1)) sl@0: sl@0: /** sl@0: * Get the amount of bytes to add to a pointer sl@0: * in order to get the next aligned address sl@0: */ sl@0: #define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr)) sl@0: sl@0: /** sl@0: * Indicate whether the ICU allocation functions have been used. sl@0: * This is used to determine whether ICU is in an initial, unused state. sl@0: */ sl@0: U_CFUNC UBool sl@0: cmemory_inUse(void); sl@0: sl@0: /** sl@0: * Heap clean up function, called from u_cleanup() sl@0: * Clears any user heap functions from u_setMemoryFunctions() sl@0: * Does NOT deallocate any remaining allocated memory. sl@0: */ sl@0: U_CFUNC UBool sl@0: cmemory_cleanup(void); sl@0: sl@0: #endif