Line | |
---|
1 | /** @file
|
---|
2 | * Memory RTL function wrappers for GCC.
|
---|
3 | *
|
---|
4 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include <os2sel.h>
|
---|
8 |
|
---|
9 | extern "C"
|
---|
10 | {
|
---|
11 |
|
---|
12 | // these are GCC kLIBC exports
|
---|
13 | void _std_malloc(size_t sz);
|
---|
14 | void *_std_realloc(void *ptr, size_t sz);
|
---|
15 | void *_std_calloc(size_t cnt, size_t sz);
|
---|
16 | void _std_free(void *ptr);
|
---|
17 |
|
---|
18 | void malloc(size_t sz)
|
---|
19 | {
|
---|
20 | unsigned short sel = RestoreOS2FS();
|
---|
21 | void *ptr = _std_malloc(sz);
|
---|
22 | SetFS(sel);
|
---|
23 | return ptr;
|
---|
24 | }
|
---|
25 |
|
---|
26 | void *realloc(void *ptr, size_t sz)
|
---|
27 | {
|
---|
28 | unsigned short sel = RestoreOS2FS();
|
---|
29 | void *newPtr = _std_realloc(ptr, sz);
|
---|
30 | SetFS(sel);
|
---|
31 | return newPtr;
|
---|
32 | }
|
---|
33 |
|
---|
34 | void *calloc(size_t cnt, size_t sz)
|
---|
35 | {
|
---|
36 | unsigned short sel = RestoreOS2FS();
|
---|
37 | void *ptr = _std_calloc(cnt, sz);
|
---|
38 | SetFS(sel);
|
---|
39 | return rc;
|
---|
40 | }
|
---|
41 |
|
---|
42 | void free(void *ptr)
|
---|
43 | {
|
---|
44 | unsigned short sel = RestoreOS2FS();
|
---|
45 | _std_free(ptr);
|
---|
46 | SetFS(sel);
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.