1 | /******************************************************************* |
---|
2 | * File: omAllocSystem.h |
---|
3 | * Purpose: declaration of routines for low-level alloc routines |
---|
4 | * and page management |
---|
5 | * Author: obachman (Olaf Bachmann) |
---|
6 | * Created: 11/99 |
---|
7 | *******************************************************************/ |
---|
8 | #ifndef OM_ALLOC_SYSTEM_H |
---|
9 | #define OM_ALLOC_SYSTEM_H |
---|
10 | |
---|
11 | size_t omSizeOfAddr(const void* addr); |
---|
12 | size_t omSizeWOfAddr(void* addr); |
---|
13 | |
---|
14 | size_t omSizeOfLargeAddr(void* addr); |
---|
15 | #define omSizeWOfLargeAddr(addr) (omSizeOfLargeAddr(addr) >> LOG_SIZEOF_LONG) |
---|
16 | |
---|
17 | void* omAllocFromSystem(size_t size); |
---|
18 | void* omReallocFromSystem(void* addr, size_t newsize); |
---|
19 | void omFreeToSystem(void* addr); |
---|
20 | |
---|
21 | void* omReallocSizeFromSystem(void* addr, size_t oldsize, size_t newsize); |
---|
22 | void omFreeSizeToSystem(void* addr, size_t size); |
---|
23 | |
---|
24 | #define omVallocFromSystem(size) _omVallocFromSystem(size, 0) |
---|
25 | void* _omVallocFromSystem(size_t size, int fail); |
---|
26 | void omVfreeToSystem(void* page, size_t size); |
---|
27 | |
---|
28 | |
---|
29 | #ifdef OM_MALLOC_PROVIDES_SIZEOF_ADDR |
---|
30 | #define omAllocLarge(size) omAllocFromSystem(OM_ALIGN_SIZE(size)) |
---|
31 | #define omReallocLarge(addr, new_size) omReallocSizeFromSystem(addr, omSizeOfLargeAddr(addr), OM_ALIGN_SIZE(new_size)) |
---|
32 | #define omFreeLarge(addr) omFreeSizeToSystem(addr, omSizeOfLargeAddr(addr)) |
---|
33 | #else |
---|
34 | void* omAllocLarge(size_t size); |
---|
35 | void* omReallocLarge(void* old_addr, size_t new_size); |
---|
36 | void omFreeLarge(void* addr); |
---|
37 | #endif |
---|
38 | void* omRealloc0Large(void* old_addr, size_t new_size); |
---|
39 | void* omAlloc0Large(size_t size); |
---|
40 | |
---|
41 | #endif /* OM_ALLOC_SYSTEM_H */ |
---|