⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 malloc.c

📁 debug source code under unix platform.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * mpatrol * A library for controlling and tracing dynamic memory allocations. * Copyright (C) 1997-2002 Graeme S. Roy <graeme.roy@analog.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307, USA. *//* * Dynamic memory allocation functions and memory operation functions. * Overrides the standard library definitions of these functions if they * haven't already been overridden by the mpatrol.h header file. */#include "inter.h"#if MP_IDENT_SUPPORT#ident "$Id: malloc.c,v 1.32 2002/01/08 20:13:59 graeme Exp $"#else /* MP_IDENT_SUPPORT */static MP_CONST MP_VOLATILE char *malloc_id = "$Id: malloc.c,v 1.32 2002/01/08 20:13:59 graeme Exp $";#endif /* MP_IDENT_SUPPORT */#ifdef __cplusplusextern "C"{#endif /* __cplusplus *//* Allocate an uninitialised memory block of a given size. */#ifdef malloc#undef malloc#endif /* malloc */MP_APIvoid *malloc(size_t l){    return __mp_alloc(l, 0, AT_MALLOC, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(malloc)(size_t l){    return __mp_alloc(l, 0, AT_MALLOC, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Allocate a zero-initialised memory block to hold enough space for an * array of elements of a given size. */#ifdef calloc#undef calloc#endif /* calloc */MP_APIvoid *calloc(size_t l, size_t n){    return __mp_alloc(l * n, 0, AT_CALLOC, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(calloc)(size_t l, size_t n){    return __mp_alloc(l * n, 0, AT_CALLOC, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Allocate an uninitialised memory block of a given size and alignment. */#ifdef memalign#undef memalign#endif /* memalign */MP_APIvoid *memalign(size_t a, size_t l){    return __mp_alloc(l, a, AT_MEMALIGN, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(memalign)(size_t a, size_t l){    return __mp_alloc(l, a, AT_MEMALIGN, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Allocate an uninitialised memory block of a given size and aligned to * the system page size. */#ifdef valloc#undef valloc#endif /* valloc */MP_APIvoid *valloc(size_t l){    return __mp_alloc(l, 0, AT_VALLOC, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(valloc)(size_t l){    return __mp_alloc(l, 0, AT_VALLOC, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Allocate an uninitialised number of pages from the system. */#ifdef pvalloc#undef pvalloc#endif /* pvalloc */MP_APIvoid *pvalloc(size_t l){    return __mp_alloc(l, 0, AT_PVALLOC, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(pvalloc)(size_t l){    return __mp_alloc(l, 0, AT_PVALLOC, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Allocate a temporary uninitialised memory block of a given size. */#ifdef alloca#undef alloca#endif /* alloca */MP_APIvoid *alloca(size_t l){    return __mp_alloc(l, 0, AT_ALLOCA, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(alloca)(size_t l){    return __mp_alloc(l, 0, AT_ALLOCA, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Duplicate an existing string using memory from the heap. */#ifdef strdup#undef strdup#endif /* strdup */MP_APIchar *strdup(MP_CONST char *p){    return __mp_strdup((char *) p, 0, AT_STRDUP, NULL, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIchar *MP_ALTFUNCNAME(strdup)(MP_CONST char *p){    return __mp_strdup((char *) p, 0, AT_STRDUP, NULL, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Duplicate an existing string using memory from the heap, but set a limit * on the size of the memory allocated for the new string. */#ifdef strndup#undef strndup#endif /* strndup */MP_APIchar *strndup(MP_CONST char *p, size_t l){    return __mp_strdup((char *) p, l, AT_STRNDUP, NULL, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIchar *MP_ALTFUNCNAME(strndup)(MP_CONST char *p, size_t l){    return __mp_strdup((char *) p, l, AT_STRNDUP, NULL, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Duplicate an existing string using memory from the heap. */#ifdef strsave#undef strsave#endif /* strsave */MP_APIchar *strsave(MP_CONST char *p){    return __mp_strdup((char *) p, 0, AT_STRSAVE, NULL, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIchar *MP_ALTFUNCNAME(strsave)(MP_CONST char *p){    return __mp_strdup((char *) p, 0, AT_STRSAVE, NULL, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Duplicate an existing string using memory from the heap, but set a limit * on the size of the memory allocated for the new string. */#ifdef strnsave#undef strnsave#endif /* strnsave */MP_API#if SYSTEM == SYSTEM_DGUXchar *strnsave(MP_CONST char *p, int l)#else /* SYSTEM */char *strnsave(MP_CONST char *p, size_t l)#endif /* SYSTEM */{    return __mp_strdup((char *) p, l, AT_STRNSAVE, NULL, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_API#if SYSTEM == SYSTEM_DGUXchar *MP_ALTFUNCNAME(strnsave)(MP_CONST char *p, int l)#else /* SYSTEM */char *MP_ALTFUNCNAME(strnsave)(MP_CONST char *p, size_t l)#endif /* SYSTEM */{    return __mp_strdup((char *) p, l, AT_STRNSAVE, NULL, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Duplicate an existing string using temporary memory from the heap. */#ifdef strdupa#undef strdupa#endif /* strdupa */MP_APIchar *strdupa(MP_CONST char *p){    return __mp_strdup((char *) p, 0, AT_STRDUPA, NULL, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIchar *MP_ALTFUNCNAME(strdupa)(MP_CONST char *p){    return __mp_strdup((char *) p, 0, AT_STRDUPA, NULL, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Duplicate an existing string using temporary memory from the heap, but set a * limit on the size of the memory allocated for the new string. */#ifdef strndupa#undef strndupa#endif /* strndupa */MP_APIchar *strndupa(MP_CONST char *p, size_t l){    return __mp_strdup((char *) p, l, AT_STRNDUPA, NULL, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIchar *MP_ALTFUNCNAME(strndupa)(MP_CONST char *p, size_t l){    return __mp_strdup((char *) p, l, AT_STRNDUPA, NULL, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Resize an existing block of memory. */#ifdef realloc#undef realloc#endif /* realloc */MP_APIvoid *realloc(void *p, size_t l){    return __mp_realloc(p, l, 0, AT_REALLOC, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(realloc)(void *p, size_t l){    return __mp_realloc(p, l, 0, AT_REALLOC, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Resize an existing block of memory but free the block if no memory is * available to resize it. */#ifdef reallocf#undef reallocf#endif /* reallocf */MP_APIvoid *reallocf(void *p, size_t l){    return __mp_realloc(p, l, 0, AT_REALLOCF, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(reallocf)(void *p, size_t l){    return __mp_realloc(p, l, 0, AT_REALLOCF, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Resize an existing block of memory, usually a block allocated by calloc(). */#ifdef recalloc#undef recalloc#endif /* recalloc */MP_APIvoid *recalloc(void *p, size_t l, size_t n){    return __mp_realloc(p, l * n, 0, AT_RECALLOC, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(recalloc)(void *p, size_t l, size_t n){    return __mp_realloc(p, l * n, 0, AT_RECALLOC, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Resize an existing block of memory, but never relocate it. */#ifdef expand#undef expand#endif /* expand */MP_APIvoid *expand(void *p, size_t l){    return __mp_realloc(p, l, 0, AT_EXPAND, NULL, NULL, 0, NULL, 0, 1);}#if MP_ALTFUNCNAMESMP_APIvoid *MP_ALTFUNCNAME(expand)(void *p, size_t l){    return __mp_realloc(p, l, 0, AT_EXPAND, NULL, NULL, 0, NULL, 0, 1);}#endif /* MP_ALTFUNCNAMES *//* Free an existing block of memory. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -