2 * file that facilitates C++ program debugging.
4 * Copyright 1995 by Gray Watson
6 * This file is part of the dmalloc package.
8 * Permission to use, copy, modify, and distribute this software for any
9 * NON-COMMERCIAL purpose and without fee is hereby granted, provided
10 * that the above copyright notice and this permission notice appear
11 * in all copies, and that the name of Gray Watson not be used in
12 * advertising or publicity pertaining to distribution of the document
13 * or software without specific, written prior permission.
15 * Please see the PERMISSIONS file or contact the author for information
16 * about commercial licenses.
18 * Gray Watson makes no representations about the suitability of the
19 * software described herein for any purpose. It is provided "as is"
20 * without express or implied warranty.
22 * The author may be contacted via http://www.letters.com/~gray/
28 * This file is used to effectively redirect new to the more familiar
29 * malloc and delete to the more familiar free so they can be debugged
30 * with the debug malloc library.. They also give the known error
33 * Compile and link this in with the C++ program you want to debug.
35 * NOTE: I am not a C++ hacker so feedback in the form of other hints
36 * and ideas for C++ users would be much appreciated.
44 #include "/usr/local/src/dmalloc-4.1.2/return.h"
48 * An overload function for the C++ new.
51 operator new(size_t size
)
56 /* handle correct C++ semantics for an alloc of size 0 */
58 if (size
== 0) size
= 1;
60 return _malloc_leap(file
, 0, size
);
64 * An overload function for the C++ new[].
67 operator new[](size_t size
)
72 /* handle correct C++ semantics for an alloc of size 0 */
74 if (size
== 0) size
= 1;
76 return _malloc_leap(file
, 0, size
);
80 * An overload function for the C++ delete.
83 operator delete(void *pnt
)
87 _free_leap(file
, 0, pnt
);
91 * An overload function for the C++ delete[]. Thanks to Jens Krinke
95 operator delete[](void *pnt
)
99 _free_leap(file
, 0, pnt
);