1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/* 18 * DESCRIPTION: 19 * The XPL_Memory.h header file contains constants and function prototypes 20 * for memory management 21 */ 22 23#ifndef XPL_MEMORY_H 24#define XPL_MEMORY_H 25 26#ifdef __cplusplus 27extern "C" { 28#endif 29 30/************** HEADER FILE INCLUDES *****************************************/ 31 32#include <stddef.h> 33#include <string.h> 34#include "xpl_Types.h" 35 36/************** CONSTANTS ****************************************************/ 37 38#define xplAllocMem(bufsize) xplAllocMemEx(bufsize,__FILE__,__LINE__) 39#define xplFreeMem(buf) { xplFreeMemEx(buf,__FILE__,__LINE__); (buf) = XPL_NULL; } 40 41 42#define XPL_FreeAndSetNull(_x) \ 43 if ((_x)!=NULL) { xplFreeMem(_x); (_x)=XPL_NULL; } 44 45 46/*============================================================================== 47 FUNCTION PROTOTYPES 48================================================================================*/ 49 50/* Allocates memory buffer */ 51void * xplAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine ); 52 53/* Deallocate memory buffer */ 54void xplFreeMemEx(void *ptr, CPCHAR szFile, int nLine); 55 56 57#ifdef __cplusplus 58} 59#endif 60 61#endif /* XPL_MEMORY_H */ 62