~ubuntu-branches/ubuntu/hoary/kvirc/hoary

« back to all changes in this revision

Viewing changes to src/kvicore/kvi_malloc.h

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2004-12-14 15:32:19 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041214153219-fdink3gyp2s20b6g
Tags: 2:2.1.3.1-2
* Change Recommends on xmms to a Suggests.
* Rebuild against KDE 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _KVI_MALLOC_H_INCLUDED_
2
 
#define _KVI_MALLOC_H_INCLUDED_
3
 
 
4
 
//
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
7
 
//
8
 
//   This file is part of the KVirc irc client distribution
9
 
//   Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
10
 
//
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.
15
 
//
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.
20
 
//
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.
24
 
//
25
 
 
26
 
#include <stdlib.h>
27
 
 
28
 
#include "kvi_settings.h"
29
 
 
30
 
#ifdef COMPILE_GCC_MEMORY_PROFILE
31
 
 
32
 
        extern void * kvi_malloc(int size);
33
 
        extern void * kvi_realloc(void * ptr,int size);
34
 
        extern void   kvi_free(void * ptr);
35
 
 
36
 
#else
37
 
 
38
 
        #ifdef COMPILE_SKIP_MEMORY_CHECKS
39
 
 
40
 
                #define kvi_malloc(__size_) malloc(__size_)
41
 
                #define kvi_realloc(__ptr_,__size_) realloc((void *)__ptr_,__size_)
42
 
 
43
 
        #else
44
 
 
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_)
48
 
        
49
 
                #ifndef _KVI_MALLOC_CPP_
50
 
                        extern void outOfMemory();
51
 
                #endif
52
 
 
53
 
                inline void * kvi_safe_malloc(int size)
54
 
                {
55
 
                        void * ptr = malloc(size);
56
 
                        if(!ptr)outOfMemory();
57
 
                        return ptr;
58
 
                }
59
 
 
60
 
                inline void * kvi_safe_realloc(void * ptr,int size)
61
 
                {
62
 
                        ptr = realloc(ptr,size);
63
 
                        if(!ptr)outOfMemory();
64
 
                        return ptr;
65
 
                }
66
 
 
67
 
        #endif //COMPILE_SKIP_MEMORY_CHECKS
68
 
 
69
 
        #define kvi_free(__ptr_) free((void *)__ptr_)
70
 
 
71
 
#endif
72
 
 
73
 
 
74
 
#endif //_KVI_MALLOC_H_INCLUDED_