os/textandloc/fontservices/textshaperplugin/IcuSource/common/cmemory.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 ******************************************************************************
     3 *
     4 *   Copyright (C) 1997-2003, International Business Machines
     5 *   Corporation and others.  All Rights Reserved.
     6 *
     7 ******************************************************************************
     8 *
     9 * File CMEMORY.H
    10 *
    11 *  Contains stdlib.h/string.h memory functions
    12 *
    13 * @author       Bertrand A. Damiba
    14 *
    15 * Modification History:
    16 *
    17 *   Date        Name        Description
    18 *   6/20/98     Bertrand    Created.
    19 *  05/03/99     stephen     Changed from functions to macros.
    20 *
    21 ******************************************************************************
    22 */
    23 
    24 #ifndef CMEMORY_H
    25 #define CMEMORY_H
    26 
    27 #include "unicode/utypes.h"
    28 #include <string.h>
    29 
    30 
    31 #define uprv_memcpy(dst, src, size) U_STANDARD_CPP_NAMESPACE memcpy(dst, src, size)
    32 #define uprv_memmove(dst, src, size) U_STANDARD_CPP_NAMESPACE memmove(dst, src, size)
    33 #define uprv_memset(buffer, mark, size) U_STANDARD_CPP_NAMESPACE memset(buffer, mark, size)
    34 #define uprv_memcmp(buffer1, buffer2, size) U_STANDARD_CPP_NAMESPACE memcmp(buffer1, buffer2,size)
    35 
    36 U_CAPI void * U_EXPORT2
    37 uprv_malloc(size_t s);
    38 
    39 U_CAPI void * U_EXPORT2
    40 uprv_realloc(void *mem, size_t size);
    41 
    42 U_CAPI void U_EXPORT2
    43 uprv_free(void *mem);
    44 
    45 /**
    46  * This should align the memory properly on any machine.
    47  * This is very useful for the safeClone functions.
    48  */
    49 typedef union {
    50     long    t1;
    51     double  t2;
    52     void   *t3;
    53 } UAlignedMemory;
    54 
    55 /**
    56  * Get the amount of bytes that a pointer is off by from
    57  * the previous aligned pointer
    58  */
    59 #define U_ALIGNMENT_OFFSET(ptr) (((size_t)ptr) & (sizeof(UAlignedMemory) - 1))
    60 
    61 /**
    62  * Get the amount of bytes to add to a pointer
    63  * in order to get the next aligned address
    64  */
    65 #define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr))
    66 
    67 /**
    68   *  Indicate whether the ICU allocation functions have been used.
    69   *  This is used to determine whether ICU is in an initial, unused state.
    70   */
    71 U_CFUNC UBool 
    72 cmemory_inUse(void);
    73 
    74 /**
    75   *  Heap clean up function, called from u_cleanup()
    76   *    Clears any user heap functions from u_setMemoryFunctions()
    77   *    Does NOT deallocate any remaining allocated memory.
    78   */
    79 U_CFUNC UBool 
    80 cmemory_cleanup(void);
    81 
    82 #endif