| 1 | /* $Id: malloc.cpp,v 1.3 1999-12-01 00:12:26 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 4 | * Memory RTL function wrappers
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1999 Sander van Leeuwen
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #undef __DEBUG_ALLOC__
|
|---|
| 11 | #include <malloc.h>
|
|---|
| 12 | #include <umalloc.h>
|
|---|
| 13 | #include <os2sel.h>
|
|---|
| 14 |
|
|---|
| 15 | void * _IMPORT _LNK_CONV _debug_calloc( size_t, size_t, const char *, size_t );
|
|---|
| 16 | void _IMPORT _LNK_CONV _debug_free( void *, const char *, size_t );
|
|---|
| 17 | void * _IMPORT _LNK_CONV _debug_malloc( size_t, const char *, size_t );
|
|---|
| 18 | void * _IMPORT _LNK_CONV _debug_realloc( void *, size_t, const char *, size_t );
|
|---|
| 19 | void * _IMPORT _LNK_CONV _debug_umalloc(Heap_t , size_t , const char *,size_t);
|
|---|
| 20 | void * _IMPORT _LNK_CONV _debug_ucalloc(Heap_t , size_t, size_t ,const char *,size_t);
|
|---|
| 21 |
|
|---|
| 22 | void * _LNK_CONV os2calloc( size_t a, size_t b )
|
|---|
| 23 | {
|
|---|
| 24 | unsigned short sel = RestoreOS2FS();
|
|---|
| 25 | void *rc;
|
|---|
| 26 |
|
|---|
| 27 | rc = calloc(a,b);
|
|---|
| 28 | SetFS(sel);
|
|---|
| 29 | return rc;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | void _LNK_CONV os2free( void *a )
|
|---|
| 33 | {
|
|---|
| 34 | unsigned short sel = RestoreOS2FS();
|
|---|
| 35 |
|
|---|
| 36 | free(a);
|
|---|
| 37 | SetFS(sel);
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | void * _LNK_CONV os2malloc( size_t a)
|
|---|
| 41 | {
|
|---|
| 42 | unsigned short sel = RestoreOS2FS();
|
|---|
| 43 | void *rc;
|
|---|
| 44 |
|
|---|
| 45 | rc = malloc(a);
|
|---|
| 46 | SetFS(sel);
|
|---|
| 47 | return rc;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | void * _LNK_CONV os2realloc( void *a, size_t b)
|
|---|
| 51 | {
|
|---|
| 52 | unsigned short sel = RestoreOS2FS();
|
|---|
| 53 | void *rc;
|
|---|
| 54 |
|
|---|
| 55 | rc = realloc(a, b);
|
|---|
| 56 | SetFS(sel);
|
|---|
| 57 | return rc;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | void * _LNK_CONV os2_debug_calloc( size_t a, size_t b, const char *c, size_t d)
|
|---|
| 61 | {
|
|---|
| 62 | unsigned short sel = RestoreOS2FS();
|
|---|
| 63 | void *rc;
|
|---|
| 64 |
|
|---|
| 65 | rc = _debug_calloc(a,b,c,d);
|
|---|
| 66 | SetFS(sel);
|
|---|
| 67 | return rc;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | void _LNK_CONV os2_debug_free( void *a, const char *b, size_t c)
|
|---|
| 71 | {
|
|---|
| 72 | unsigned short sel = RestoreOS2FS();
|
|---|
| 73 |
|
|---|
| 74 | _debug_free(a,b,c);
|
|---|
| 75 | SetFS(sel);
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | void * _LNK_CONV os2_debug_malloc( size_t a, const char *b, size_t c)
|
|---|
| 79 | {
|
|---|
| 80 | unsigned short sel = RestoreOS2FS();
|
|---|
| 81 | void *rc;
|
|---|
| 82 |
|
|---|
| 83 | rc = _debug_malloc(a,b,c);
|
|---|
| 84 | SetFS(sel);
|
|---|
| 85 | return rc;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | void * _LNK_CONV os2_debug_realloc( void *a, size_t b, const char *c, size_t d)
|
|---|
| 89 | {
|
|---|
| 90 | unsigned short sel = RestoreOS2FS();
|
|---|
| 91 | void *rc;
|
|---|
| 92 |
|
|---|
| 93 | rc = _debug_realloc(a,b,c,d);
|
|---|
| 94 | SetFS(sel);
|
|---|
| 95 | return rc;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | void * _LNK_CONV os2_umalloc(Heap_t a, size_t b)
|
|---|
| 99 | {
|
|---|
| 100 | unsigned short sel = RestoreOS2FS();
|
|---|
| 101 | void *rc;
|
|---|
| 102 |
|
|---|
| 103 | rc = _umalloc(a,b);
|
|---|
| 104 | SetFS(sel);
|
|---|
| 105 | return rc;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | void * _LNK_CONV os2_ucalloc(Heap_t a, size_t b, size_t c)
|
|---|
| 109 | {
|
|---|
| 110 | unsigned short sel = RestoreOS2FS();
|
|---|
| 111 | void *rc;
|
|---|
| 112 |
|
|---|
| 113 | rc = _ucalloc(a,b,c);
|
|---|
| 114 | SetFS(sel);
|
|---|
| 115 | return rc;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | void * _LNK_CONV os2_debug_umalloc(Heap_t a, size_t b, const char *c, size_t d)
|
|---|
| 119 | {
|
|---|
| 120 | unsigned short sel = RestoreOS2FS();
|
|---|
| 121 | void *rc;
|
|---|
| 122 |
|
|---|
| 123 | rc = _debug_umalloc(a,b,c,d);
|
|---|
| 124 | SetFS(sel);
|
|---|
| 125 | return rc;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | void * _LNK_CONV os2_debug_ucalloc(Heap_t a, size_t b, size_t c, const char *d, size_t e)
|
|---|
| 129 | {
|
|---|
| 130 | unsigned short sel = RestoreOS2FS();
|
|---|
| 131 | void *rc;
|
|---|
| 132 |
|
|---|
| 133 | rc = _debug_ucalloc(a,b,c,d,e);
|
|---|
| 134 | SetFS(sel);
|
|---|
| 135 | return rc;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|