os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfmemory.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfmemory.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,70 @@
1.4 +/* Copyright (c) 2009 The Khronos Group Inc.
1.5 + * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies)
1.6 + *
1.7 + * Permission is hereby granted, free of charge, to any person obtaining a
1.8 + * copy of this software and/or associated documentation files (the
1.9 + * "Materials"), to deal in the Materials without restriction, including
1.10 + * without limitation the rights to use, copy, modify, merge, publish,
1.11 + * distribute, sublicense, and/or sell copies of the Materials, and to
1.12 + * permit persons to whom the Materials are furnished to do so, subject to
1.13 + * the following conditions:
1.14 + *
1.15 + * The above copyright notice and this permission notice shall be included
1.16 + * in all copies or substantial portions of the Materials.
1.17 + *
1.18 + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1.19 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1.20 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1.21 + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1.22 + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1.23 + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1.24 + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1.25 + */
1.26 +#ifndef OWFMEMORY_H_
1.27 +#define OWFMEMORY_H_
1.28 +
1.29 +#include <stdlib.h>
1.30 +#include "owftypes.h"
1.31 +#include "owfdebug.h"
1.32 +
1.33 +#ifdef __cplusplus
1.34 +extern "C"
1.35 +{
1.36 +#endif
1.37 +
1.38 +
1.39 +#ifdef DEBUG
1.40 +
1.41 +/*
1.42 + * In debug builds we use our own memory management functions:
1.43 + */
1.44 +/* multiplication yields negative if overflowed */
1.45 +#define xalloc(n, c) (((OWFint)n*c < c) ? NULL : OWF_Memory_Alloc(__FILE__, __LINE__, (n)*(c)))
1.46 +#define xfree(p) OWF_Memory_Free(p)
1.47 +
1.48 +#else
1.49 +
1.50 +#define xalloc(n, c) calloc(n, c)
1.51 +#define xfree(p) free(p)
1.52 +
1.53 +#endif
1.54 +
1.55 +#define NEW0N(x, n) (x*) xalloc(sizeof(x), n)
1.56 +#define NEW0(x) NEW0N(x, 1)
1.57 +
1.58 +OWF_API_CALL void*
1.59 +OWF_Memory_Alloc(const char* file, OWFint line, OWFuint32 size);
1.60 +
1.61 +OWF_API_CALL void
1.62 +OWF_Memory_Free(void* ptr);
1.63 +
1.64 +OWF_API_CALL void
1.65 +OWF_Memory_BlockDump();
1.66 +
1.67 +
1.68 +#ifdef __cplusplus
1.69 +}
1.70 +#endif
1.71 +
1.72 +
1.73 +#endif