os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfmemory.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.
     1 /* Copyright (c) 2009 The Khronos Group Inc.
     2  * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
     3  *
     4  * Permission is hereby granted, free of charge, to any person obtaining a
     5  * copy of this software and/or associated documentation files (the
     6  * "Materials"), to deal in the Materials without restriction, including
     7  * without limitation the rights to use, copy, modify, merge, publish,
     8  * distribute, sublicense, and/or sell copies of the Materials, and to
     9  * permit persons to whom the Materials are furnished to do so, subject to
    10  * the following conditions:
    11  *
    12  * The above copyright notice and this permission notice shall be included
    13  * in all copies or substantial portions of the Materials.
    14  *
    15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    21  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
    22  */
    23 #ifndef OWFMEMORY_H_
    24 #define OWFMEMORY_H_
    25 
    26 #include <stdlib.h>
    27 #include "owftypes.h"
    28 #include "owfdebug.h"
    29 
    30 #ifdef __cplusplus
    31 extern "C"
    32 {
    33 #endif
    34 
    35 
    36 #ifdef DEBUG
    37 
    38 /*
    39  * In debug builds we use our own memory management functions:
    40  */
    41 /* multiplication yields negative if overflowed */
    42 #define xalloc(n, c)        (((OWFint)n*c < c) ? NULL : OWF_Memory_Alloc(__FILE__, __LINE__, (n)*(c)))
    43 #define xfree(p)            OWF_Memory_Free(p)
    44 
    45 #else
    46 
    47 #define xalloc(n, c)        calloc(n, c)
    48 #define xfree(p)            free(p)
    49 
    50 #endif
    51 
    52 #define NEW0N(x, n)         (x*) xalloc(sizeof(x), n)
    53 #define NEW0(x)             NEW0N(x, 1)
    54 
    55 OWF_API_CALL void*
    56 OWF_Memory_Alloc(const char* file, OWFint line, OWFuint32 size);
    57 
    58 OWF_API_CALL void
    59 OWF_Memory_Free(void* ptr);
    60 
    61 OWF_API_CALL void
    62 OWF_Memory_BlockDump();
    63 
    64 
    65 #ifdef __cplusplus
    66 }
    67 #endif
    68 
    69 
    70 #endif