| 1 | #ifdef RCSID |
| 2 | static char RCSid[] = |
| 3 | "$Header$"; |
| 4 | #endif |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved. |
| 8 | * |
| 9 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 10 | * on using and copying this software. |
| 11 | */ |
| 12 | /* |
| 13 | Name |
| 14 | std_dbg.cpp - T3 standard libarary - debugging routines |
| 15 | Function |
| 16 | Provides debug versions of memory-management functions. These functions |
| 17 | are separated from the basic std.cpp routines so that they can be |
| 18 | omitted entirely if they're provided by another subsystem (for example, |
| 19 | the HTML TADS code has its own debug memory management routines; only |
| 20 | one set is required or allowed in a given executable, so we can omit |
| 21 | this version when linking with the HTML TADS code). |
| 22 | Notes |
| 23 | |
| 24 | Modified |
| 25 | 10/08/99 MJRoberts - Creation |
| 26 | */ |
| 27 | |
| 28 | #include <string.h> |
| 29 | #include <stdlib.h> |
| 30 | |
| 31 | #include "os.h" |
| 32 | #include "t3std.h" |
| 33 | #include "utf8.h" |
| 34 | |
| 35 | /* ------------------------------------------------------------------------ */ |
| 36 | /* |
| 37 | * Debugging routines for memory management |
| 38 | */ |
| 39 | |
| 40 | #ifdef T3_DEBUG |
| 41 | |
| 42 | void *operator new(size_t siz) SYSTHROW(throw (std::bad_alloc)) |
| 43 | { |
| 44 | return t3malloc(siz, T3MALLOC_TYPE_NEW); |
| 45 | } |
| 46 | |
| 47 | void operator delete(void *ptr) SYSTHROW(throw ()) |
| 48 | { |
| 49 | t3free(ptr, T3MALLOC_TYPE_NEW); |
| 50 | } |
| 51 | |
| 52 | void *operator new[](size_t siz) SYSTHROW(throw (std::bad_alloc)) |
| 53 | { |
| 54 | return t3malloc(siz, T3MALLOC_TYPE_NEWARR); |
| 55 | } |
| 56 | |
| 57 | void operator delete[](void *ptr) SYSTHROW(throw ()) |
| 58 | { |
| 59 | t3free(ptr, T3MALLOC_TYPE_NEWARR); |
| 60 | } |
| 61 | |
| 62 | #endif /* T3_DEBUG */ |