scuffed-code/icu4c/source/common/cmemory.h

64 lines
1.8 KiB
C
Raw Normal View History

1999-08-16 21:50:52 +00:00
/*
******************************************************************************
*
* Copyright (C) 1997-2001, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
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.
*
******************************************************************************
1999-08-16 21:50:52 +00:00
*/
#ifndef CMEMORY_H
#define CMEMORY_H
#include "unicode/utypes.h"
1999-08-16 21:50:52 +00:00
#include <stdlib.h>
#include <string.h>
#define uprv_malloc(size) U_STANDARD_CPP_NAMESPACE malloc(size)
#define uprv_realloc(buffer, size) U_STANDARD_CPP_NAMESPACE realloc(buffer, size)
#define uprv_free(buffer) U_STANDARD_CPP_NAMESPACE free(buffer)
#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
/**
* 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
*/
#define U_ALIGNMENT_OFFSET(ptr) (((size_t)ptr) & (sizeof(UAlignedMemory) - 1))
/**
* 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))
1999-08-16 21:50:52 +00:00
#endif