]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/cmemory.c
2 ******************************************************************************
4 * Copyright (C) 2002, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
9 * File cmemory.c ICU Heap allocation.
10 * All ICU heap allocation, both for C and C++ new of ICU
11 * class types, comes through these functions.
13 * If you have a need to replace ICU allocation, this is the
16 * Note that uprv_malloc(0) returns a non-NULL pointer, and
17 * that a subsequent free of that pointer value is a NOP.
19 ******************************************************************************
23 /* uprv_malloc(0) returns a pointer to this read-only data. */
24 static const int32_t zeroMem
[] = {0, 0, 0, 0, 0, 0};
26 U_CAPI
void * U_EXPORT2
27 uprv_malloc(size_t s
) {
31 return (void *)zeroMem
;
35 U_CAPI
void * U_EXPORT2
36 uprv_realloc(void * buffer
, size_t size
) {
37 if (buffer
== zeroMem
) {
38 return uprv_malloc(size
);
39 } else if (size
== 0) {
41 return (void *)zeroMem
;
43 return realloc(buffer
, size
);
48 uprv_free(void *buffer
) {
49 if (buffer
!= zeroMem
) {