| 1 | /* $Id: new.cpp,v 1.3 1999-11-10 01:45:37 bird Exp $ | 
|---|
| 2 | * | 
|---|
| 3 | * new - new and delete operators. | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (c) 1998-1999 knut st. osmundsen | 
|---|
| 6 | * | 
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 8 | * | 
|---|
| 9 | */ | 
|---|
| 10 |  | 
|---|
| 11 | /******************************************************************************* | 
|---|
| 12 | *   Defined Constants                                                          * | 
|---|
| 13 | *******************************************************************************/ | 
|---|
| 14 | #define INCL_DOS | 
|---|
| 15 | #define INCL_DOSERRORS | 
|---|
| 16 | #define INCL_NOAPI | 
|---|
| 17 |  | 
|---|
| 18 | /******************************************************************************* | 
|---|
| 19 | *   Header Files                                                               * | 
|---|
| 20 | *******************************************************************************/ | 
|---|
| 21 | #include <os2.h> | 
|---|
| 22 |  | 
|---|
| 23 | #include "new.h" | 
|---|
| 24 | #include "malloc.h" | 
|---|
| 25 | #include "log.h" | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | #pragma info(none) | 
|---|
| 29 | /** | 
|---|
| 30 | * New. | 
|---|
| 31 | * @returns   pointer to allocated memory. | 
|---|
| 32 | * @param     Size  Size requested. | 
|---|
| 33 | */ | 
|---|
| 34 | void *operator new(size_t size) | 
|---|
| 35 | { | 
|---|
| 36 | return malloc(size); | 
|---|
| 37 | } | 
|---|
| 38 |  | 
|---|
| 39 |  | 
|---|
| 40 | /** | 
|---|
| 41 | * stub | 
|---|
| 42 | */ | 
|---|
| 43 | void *operator new(size_t size, void *location) | 
|---|
| 44 | { | 
|---|
| 45 | dprintf(("operator new(size,location) not implemented\n")); | 
|---|
| 46 | return NULL; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | /** | 
|---|
| 51 | * stub | 
|---|
| 52 | */ | 
|---|
| 53 | void *operator new[](size_t size) | 
|---|
| 54 | { | 
|---|
| 55 | dprintf(("operator new[](size) not implemented\n")); | 
|---|
| 56 | return NULL; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 |  | 
|---|
| 60 | /** | 
|---|
| 61 | * stub | 
|---|
| 62 | */ | 
|---|
| 63 | void *operator new[](size_t size, void *location) | 
|---|
| 64 | { | 
|---|
| 65 | dprintf(("operator new[](size,location) not implemented\n")); | 
|---|
| 66 | return NULL; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | #ifndef __DEBUG_ALLOC__ | 
|---|
| 70 | /** | 
|---|
| 71 | * Delete. | 
|---|
| 72 | * @param     location  Pointer to memory block which are to be freed. | 
|---|
| 73 | */ | 
|---|
| 74 | void operator delete(void *location) | 
|---|
| 75 | { | 
|---|
| 76 | free(location); | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 | /** | 
|---|
| 81 | * stub | 
|---|
| 82 | */ | 
|---|
| 83 | void operator delete[](void *location) | 
|---|
| 84 | { | 
|---|
| 85 | dprintf(("operator delete[](location) - not implemented\n")); | 
|---|
| 86 | } | 
|---|
| 87 | #endif | 
|---|
| 88 |  | 
|---|
| 89 | /*** | 
|---|
| 90 | *  debug! | 
|---|
| 91 | ***/ | 
|---|
| 92 |  | 
|---|
| 93 | /** | 
|---|
| 94 | * New. | 
|---|
| 95 | * @returns   pointer to allocated memory. | 
|---|
| 96 | * @param     Size  Size requested. | 
|---|
| 97 | */ | 
|---|
| 98 | void *operator new(size_t size, const char *filename, size_t lineno) | 
|---|
| 99 | { | 
|---|
| 100 | return malloc(size); | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 |  | 
|---|
| 104 | /** | 
|---|
| 105 | * stub | 
|---|
| 106 | */ | 
|---|
| 107 | void *operator new(size_t size, const char *filename, size_t lineno, void *location) | 
|---|
| 108 | { | 
|---|
| 109 | dprintf(("operator new(size,location) not implemented\n")); | 
|---|
| 110 | return NULL; | 
|---|
| 111 | } | 
|---|
| 112 |  | 
|---|
| 113 |  | 
|---|
| 114 | /** | 
|---|
| 115 | * stub | 
|---|
| 116 | */ | 
|---|
| 117 | void *operator new[](size_t size, const char *filename, size_t lineno) | 
|---|
| 118 | { | 
|---|
| 119 | dprintf(("operator new[](size) not implemented\n")); | 
|---|
| 120 | return NULL; | 
|---|
| 121 | } | 
|---|
| 122 |  | 
|---|
| 123 |  | 
|---|
| 124 | /** | 
|---|
| 125 | * stub | 
|---|
| 126 | */ | 
|---|
| 127 | void *operator new[](size_t size, const char *filename, size_t lineno, void *location) | 
|---|
| 128 | { | 
|---|
| 129 | dprintf(("operator new[](size,location) not implemented\n")); | 
|---|
| 130 | return NULL; | 
|---|
| 131 | } | 
|---|
| 132 |  | 
|---|
| 133 | #ifdef __DEBUG_ALLOC__ | 
|---|
| 134 | /** | 
|---|
| 135 | * Delete. | 
|---|
| 136 | * @param     location  Pointer to memory block which are to be freed. | 
|---|
| 137 | */ | 
|---|
| 138 | void operator delete(void *location, const char *filename, size_t lineno) | 
|---|
| 139 | { | 
|---|
| 140 | free(location); | 
|---|
| 141 | } | 
|---|
| 142 |  | 
|---|
| 143 |  | 
|---|
| 144 | /** | 
|---|
| 145 | * stub | 
|---|
| 146 | */ | 
|---|
| 147 | void operator delete[](void *location, const char *filename, size_t lineno) | 
|---|
| 148 | { | 
|---|
| 149 | dprintf(("operator delete[](location) - not implemented\n")); | 
|---|
| 150 | } | 
|---|
| 151 | #endif | 
|---|