📄 midpmalloc.h
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* midpMalloc.h
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* MIDP memory operation APIs
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*
* @(#)midpMalloc.h 1.5 02/09/24 @(#)
*
* Copyright (c) 2002 Sun Microsystems, Inc. All rights reserved.
* PROPRIETARY/CONFIDENTIAL
* Use is subject to license terms.
*/
#ifndef _MIDP_MALLOC_H
#define _MIDP_MALLOC_H
#include <stdlib.h>
#include <kal_release.h>
/**************************************************************************
* Constant Definition
**************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#define NO_STRDUP (1)
#define NO_CALLOC (1)
#define NO_REALLOC (1)
#define NO_MEMCMP (0)
#define NO_MEMCPY (0)
#define NO_MEMSET (0)
#define NO_MEMMOVE (1)
#define USE_MIDP_MALLOC (1)
/* Main define to enable/disable private handling of memory allocations */
#if USE_MIDP_MALLOC
/**************************************************************************
* Declaration
**************************************************************************/
/* extern variables for ASM */
extern long midslist_mem_pool[];
extern long *MidpMemory;
int midpInitializeMemory(long*, int);
int midpFinalizeMemory(void);
int midpGetTotalHeap(void);
int midpGetFreeHeap(void);
/* Private implementations for memory allocation */
void* midpMallocImpl(int, char*, int);
void* midpCallocImpl(int, int, char*, int);
void* midpReallocImpl(void*, int, char*, int);
char* midpStrdupImpl(const char*, char*, int);
void midpFreeImpl(void*, char*, int);
#ifdef MIDP_MALLOC_TRACE
extern int tracenativememory;
#define midpMalloc(x) midpMallocImpl((x), __FILE__, __LINE__)
#define midpCalloc(x, y) midpCallocImpl((x), (y), __FILE__, __LINE__)
#define midpRealloc(x, y) midpReallocImpl((x), (y), __FILE__, __LINE__)
#define midpStrdup(x) midpStrdupImpl((x), __FILE__, __LINE__)
#define midpFree(x) midpFreeImpl((x), __FILE__, __LINE__)
#else
#define midpMalloc(x) midpMallocImpl((x), (char*)NULL, 0)
#define midpCalloc(x, y) midpCallocImpl((x), (y), (char*)NULL, 0)
#define midpRealloc(x, y) midpReallocImpl((x), (y), (char*)NULL, 0)
#define midpStrdup(x) midpStrdupImpl((x), (char*)NULL, 0)
#define midpFree(x) midpFreeImpl((x), (char*)NULL, 0)
#endif /* MIDP_MALLOC_TRACE */
#else
/*
* We're not using our own memory manager, use the standard library
* function calls to allocate memory.
*/
#define midpInitializeMemory(addr, size)
#define midpFinalizeMemory()
#define midpGetTotalHeap() (-1)
#define midpGetFreeHeap() (-1)
#if NO_CALLOC
extern void* Kcalloc(size_t, size_t);
#define midpCalloc(x, y) Kcalloc((x), (y))
#else
#define midpCalloc(x, y) calloc((x), (y))
#endif /* NO_CALLOC */
#if NO_STRDUP
extern char* Kstrdup(const char*);
#define midpStrdup(x) Kstrdup((x))
#else
#define midpStrdup(x) strdup((x))
#endif /* NO_STRDUP */
#if NO_REALLOC
extern void* Krealloc(void *, size_t);
#define midpRealloc(x, y) Krealloc((x), (y))
#else
#define midpRealloc(x, y) realloc((x), (y))
#endif /* NO_REALLOC */
#endif /* USE_MIDP_MALLOC */
#if NO_MEMCMP
extern int Kmemcmp(const void *,const void *,size_t);
#else
#define Kmemcmp kal_mem_cmp
#endif /* NO_MEMCMP */
#if NO_MEMCPY
extern void *Kmemcpy(void *,const void *,size_t);
#else
#define Kmemcpy kal_mem_cpy
#endif /* NO_MEMCPY */
#if NO_MEMSET
extern void *Kmemset(void *,int,size_t);
#else
#define Kmemset kal_mem_set
#endif /* NO_MEMSET */
#if NO_MEMMOVE
extern void *Kmemmove(void *,const void *,size_t);
#else
#define Kmemmove memmove
#endif /* NO_MEMMOVE */
void midpAssertExt(char *expr, char* file, int line);
#define midpAssert(expr) if(!(expr)) { midpAssertExt(#expr, __FILE__, __LINE__); }
#ifdef __cplusplus
}
#endif
#endif /* _MIDP_MALLOC_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -