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