1
#ifndef _KVI_MALLOC_H_INCLUDED_
2
#define _KVI_MALLOC_H_INCLUDED_
5
// File : kvi_malloc.h (/usr/build/NEW_kvirc/kvirc/kvicore/kvi_malloc.h)
6
// Creation date : Mon Jan 11 1999 00:54:36 by Szymon Stefanek
8
// This file is part of the KVirc irc client distribution
9
// Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
11
// This program is FREE software. You can redistribute it and/or
12
// modify it under the terms of the GNU General Public License
13
// as published by the Free Software Foundation; either version 2
14
// of the License, or (at your opinion) any later version.
16
// This program is distributed in the HOPE that it will be USEFUL,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
// See the GNU General Public License for more details.
21
// You should have received a copy of the GNU General Public License
22
// along with this program. If not, write to the Free Software Foundation,
23
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
#include "kvi_settings.h"
30
#ifdef COMPILE_GCC_MEMORY_PROFILE
32
extern void * kvi_malloc(int size);
33
extern void * kvi_realloc(void * ptr,int size);
34
extern void kvi_free(void * ptr);
38
#ifdef COMPILE_SKIP_MEMORY_CHECKS
40
#define kvi_malloc(__size_) malloc(__size_)
41
#define kvi_realloc(__ptr_,__size_) realloc((void *)__ptr_,__size_)
45
//Want to check all the pointers
46
#define kvi_malloc(__size_) kvi_safe_malloc(__size_)
47
#define kvi_realloc(__ptr_,__size_) kvi_safe_realloc((void *)__ptr_,__size_)
49
#ifndef _KVI_MALLOC_CPP_
50
extern void outOfMemory();
53
inline void * kvi_safe_malloc(int size)
55
void * ptr = malloc(size);
56
if(!ptr)outOfMemory();
60
inline void * kvi_safe_realloc(void * ptr,int size)
62
ptr = realloc(ptr,size);
63
if(!ptr)outOfMemory();
67
#endif //COMPILE_SKIP_MEMORY_CHECKS
69
#define kvi_free(__ptr_) free((void *)__ptr_)
74
#endif //_KVI_MALLOC_H_INCLUDED_