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