1999-08-16 21:50:52 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-13 22:28:37 +00:00
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
* Copyright (C) 1997-2001, International Business Machines
|
1999-12-13 22:28:37 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File CMEMORY.H
|
|
|
|
*
|
|
|
|
* Contains stdlib.h/string.h memory functions
|
|
|
|
*
|
|
|
|
* @author Bertrand A. Damiba
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 6/20/98 Bertrand Created.
|
|
|
|
* 05/03/99 stephen Changed from functions to macros.
|
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CMEMORY_H
|
|
|
|
#define CMEMORY_H
|
|
|
|
|
2002-07-12 21:42:24 +00:00
|
|
|
#include "unicode/utypes.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2000-11-30 20:48:59 +00:00
|
|
|
|
|
|
|
#define uprv_memcpy(dst, src, size) U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size)
|
|
|
|
#define uprv_memmove(dst, src, size) U_STANDARD_CPP_NAMESPACE memmove(dst, src, size)
|
|
|
|
#define uprv_memset(buffer, mark, size) U_STANDARD_CPP_NAMESPACE memset(buffer, mark, size)
|
|
|
|
#define uprv_memcmp(buffer1, buffer2, size) U_STANDARD_CPP_NAMESPACE memcmp(buffer1, buffer2,size)
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2002-07-29 21:04:18 +00:00
|
|
|
U_CAPI void * U_EXPORT2
|
|
|
|
uprv_malloc(size_t s);
|
|
|
|
|
|
|
|
U_CAPI void * U_EXPORT2
|
|
|
|
uprv_realloc(void *mem, size_t size);
|
|
|
|
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
uprv_free(void *mem);
|
|
|
|
|
2001-09-26 21:09:18 +00:00
|
|
|
/**
|
|
|
|
* This should align the memory properly on any machine.
|
|
|
|
* This is very useful for the safeClone functions.
|
|
|
|
*/
|
|
|
|
typedef union {
|
|
|
|
long t1;
|
|
|
|
double t2;
|
|
|
|
void *t3;
|
|
|
|
} UAlignedMemory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the amount of bytes that a pointer is off by from
|
|
|
|
* the previous aligned pointer
|
|
|
|
*/
|
2002-03-29 01:51:09 +00:00
|
|
|
#define U_ALIGNMENT_OFFSET(ptr) (((size_t)ptr) & (sizeof(UAlignedMemory) - 1))
|
2001-09-26 21:09:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the amount of bytes to add to a pointer
|
|
|
|
* in order to get the next aligned address
|
|
|
|
*/
|
|
|
|
#define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr))
|
|
|
|
|
2003-08-05 01:25:54 +00:00
|
|
|
/**
|
|
|
|
* Indicate whether the ICU allocation functions have been used.
|
|
|
|
* This is used to determine whether ICU is in an initial, unused state.
|
|
|
|
*/
|
|
|
|
U_CFUNC UBool
|
|
|
|
cmemory_inUse();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark the ICU heap as not being in use, even if it is.
|
|
|
|
* Needed so that we can ignore any allocations triggered by ICU
|
|
|
|
* static initialization, and still pretend that we are in a pristine state.
|
|
|
|
* TODO: this is awkward. Think about something cleaner.
|
|
|
|
*/
|
|
|
|
U_CFUNC void
|
|
|
|
cmemory_clearInUse();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Heap clean up function, called from u_cleanup()
|
|
|
|
* Clears any user heap functions from u_setMemoryFunctions()
|
|
|
|
* Does NOT deallocate any remaining allocated memory.
|
|
|
|
*/
|
|
|
|
U_CFUNC UBool
|
|
|
|
cmemory_cleanup(void);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
#endif
|