 |
My Project
debian-1:4.1.2-p1+ds-2
|
#include <time.h>
#include <string.h>
#include <limits.h>
#include "omStructs.h"
Go to the source code of this file.
|
void | TestAlloc (omMemCell cell, unsigned long spec) |
|
void | TestRealloc (omMemCell cell, unsigned long spec) |
|
void | TestFree (omMemCell cell) |
|
void | omtTestAlloc (omMemCell cell, unsigned long spec) |
|
void | omtTestRealloc (omMemCell cell, unsigned long spec) |
|
void | omtTestDup (omMemCell cell, unsigned long spec) |
|
void | omtTestFree (omMemCell cell) |
|
void | omtTestAllocDebug (omMemCell cell, unsigned long spec) |
|
void | omtTestReallocDebug (omMemCell cell, unsigned long spec) |
|
void | omtTestDupDebug (omMemCell cell, unsigned long spec) |
|
void | omtTestFreeDebug (omMemCell cell) |
|
void | omtTestAllocKeep (omMemCell cell, unsigned long spec) |
|
void | omtTestReallocKeep (omMemCell cell, unsigned long spec) |
|
void | omtTestDupKeep (omMemCell cell, unsigned long spec) |
|
void | omtTestFreeKeep (omMemCell cell) |
|
void | InitCellAddrContent (omMemCell cell) |
|
int | omtTestErrors () |
|
omBin | omtGetStickyBin (omBin bin) |
|
void | omtTestDebug (omMemCell cell) |
|
void | TestAddrContent (void *addr, unsigned long value, size_t size) |
|
void | TestAddrContentEqual (void *s1, void *s2, size_t size) |
|
◆ omMemCell_s
Definition at line 25 of file omtTest.h.
Data Fields |
void * |
addr |
|
omBin |
bin |
|
omBin |
orig_bin |
|
unsigned long |
spec |
|
◆ CHECK_LEVEL
◆ DO_CHECK
#define DO_CHECK |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 22)) |
◆ DO_DUP
#define DO_DUP |
( |
|
spec | ) |
((spec & (((unsigned long) 1) << 20)) && ! (spec & (((unsigned long) 1) << 21))) |
◆ DO_FREE
#define DO_FREE |
( |
|
spec | ) |
(!(spec & (((unsigned long) 1) << 20)) && !(spec & (((unsigned long) 1) << 21))) |
◆ DO_FREE_CHECK
#define DO_FREE_CHECK |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 23)) |
◆ DO_FREE_KEEP
◆ DO_KEEP
◆ DO_REALLOC
#define DO_REALLOC |
( |
|
spec | ) |
((spec & (((unsigned long) 1) << 20)) && (spec & (((unsigned long) 1) << 21))) |
◆ DO_TRACK
#define DO_TRACK |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 24)) |
◆ END_CHECK_LEVEL
#define END_CHECK_LEVEL 5 |
◆ GET_SIZE
#define GET_SIZE |
( |
|
spec | ) |
(spec & ((((unsigned long) 1) << 14) -1)) |
◆ GET_TRACK
#define GET_TRACK |
( |
|
spec | ) |
(((spec & ((((unsigned long) 1) << 27) | (((unsigned long) 1) << 26) | (((unsigned long) 1) << 25))) >> 25) % 5) + TRACK_LEVEL |
◆ IS_ALIGNED
#define IS_ALIGNED |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 15)) |
◆ IS_BIN
#define IS_BIN |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 17)) |
◆ IS_FREE_BIN
#define IS_FREE_BIN |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 29)) |
◆ IS_FREE_BINADDR
#define IS_FREE_BINADDR |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 31)) |
◆ IS_FREE_SIZE
#define IS_FREE_SIZE |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 28)) |
◆ IS_INLINE
#define IS_INLINE |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 19)) |
◆ IS_SLOPPY
#define IS_SLOPPY |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 30)) |
◆ IS_SPEC_BIN
#define IS_SPEC_BIN |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 18)) |
◆ IS_STICKY_BIN
#define IS_STICKY_BIN |
( |
|
spec | ) |
(spec & 1) |
◆ IS_ZERO
#define IS_ZERO |
( |
|
spec | ) |
(spec & (((unsigned long) 1) << 16)) |
◆ KEEP_ADDR
◆ KEEP_LEVEL
◆ MAX_CELLS
◆ myfflush
#define myfflush |
( |
|
what | ) |
do {} while (0) |
◆ myprintf
#define myprintf |
( |
|
format, |
|
|
|
args... |
|
) |
| do {} while (0) |
◆ PAGES_PER_REGION
#define PAGES_PER_REGION 128 |
◆ RANGE_MAX
#define RANGE_MAX (((unsigned long) 1) << 14) |
◆ RANGE_MIN
#define RANGE_MIN (((unsigned long) 1) << 6) |
◆ SET_SIZE
#define SET_SIZE |
( |
|
spec, |
|
|
|
size |
|
) |
| spec = ((spec & ~((((unsigned long) 1) << 14) -1)) | (size)) |
◆ SIZE_MAX
#define SIZE_MAX ((((unsigned long) 1) << 14) -1) |
◆ SPEC_MAX
#define SPEC_MAX ULONG_MAX |
◆ TRACK_LEVEL
◆ omMemCell
◆ InitCellAddrContent()
◆ omtGetStickyBin()
◆ omtTestAlloc()
void omtTestAlloc |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ omtTestAllocDebug()
void omtTestAllocDebug |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ omtTestAllocKeep()
void omtTestAllocKeep |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ omtTestDebug()
Definition at line 34 of file omtTest.c.
40 if (cell->bin !=
NULL)
56 if (!OM_IS_ALIGNED(cell->addr))
59 "addr:%p is unaligned", cell->addr);
63 if (
IS_ALIGNED(cell->spec) && !OM_IS_STRICT_ALIGNED(cell->addr))
66 "addr:%p is not strict unaligned", cell->addr);
71 if (!OM_IS_ALIGNED(is_size))
74 "is_size == %u is unaligned", is_size);
80 "is_size==%u < size==%u", is_size,
size);
87 "is_sizeW==%u < sizeW==%u", is_size >> LOG_SIZEOF_LONG,
omSizeWOfAddr(cell->addr));
◆ omtTestDup()
void omtTestDup |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
Definition at line 346 of file omtTestAlloc.c.
355 memset(cell->addr,
'a',
size - 1);
356 ((
char*) cell->addr)[
size-1] =
'\0';
364 void* new_addr =
omMemDup(cell->addr);
◆ omtTestDupDebug()
void omtTestDupDebug |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ omtTestDupKeep()
void omtTestDupKeep |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ omtTestErrors()
Definition at line 36 of file omtTestError.c.
42 int missed = 0, alloc;
45 printf(
"omtTestErrors: Start\n");
52 memset(&spec, 0,
sizeof(
struct LongSpec));
66 bin->last_page =
NULL;
68 bin->last_page = last_page;
70 else printf(
"cell not found\n");
96 else printf(
"cell not found\n");
109 else printf(
"cell not found\n");
140 else printf(
"cell not found");
143 else printf(
"cell not found\n");
146 else printf(
"cell not found\n");
156 addr = *((
void**) addr);
167 addr = *((
void**) addr);
178 printf(
"addr not found\n");
194 else printf(
"cell not found\n");
211 page->region = region;
213 else printf(
"cell not found\n");
226 else printf(
"cell not found\n");
238 else printf(
"cell not found\n");
251 else printf(
"cell not found");
262 else printf(
"cell not found\n");
282 }
else printf(
"last == NULL\n");
294 }
else printf(
"om_SpecBin->next == NULL\n");
309 else printf(
"om_KeptAddr == NULL\n");
324 value = *((
void**) cell->addr);
325 *((
void**) cell->addr) = value -1;
327 *((
void**) cell->addr) = value;
331 else printf(
"cell not found\n");
333 else printf(
"om_Opts.Keep == 0");
345 void* value = *((
void**) addr);
346 *((
void**) addr) = value -1;
348 *((
void**) addr) = value;
350 else printf(
"cell not found\n");
360 void* addr = cell->addr - SIZEOF_VOIDP;
361 void* value = *((
void**) addr);
362 *((
void**) addr) = value -1;
364 *((
void**) addr) = value;
366 else printf(
"cell not found\n");
378 char* addr = (
char*) cell->addr;
386 else printf(
"cell not found\n");
400 printf(
"No Error test implemented\n");
425 printf(
"omtTest panik: memory corrupted\n\n");
430 printf(
"omtTestErrors: Summary: missed = %d\n\n", missed);
◆ omtTestFree()
Definition at line 133 of file omtTestAlloc.c.
136 void* addr = cell->addr;
137 unsigned long spec = cell->spec;
138 omBin bin = cell->bin;
139 omBin orig_bin = cell->orig_bin;
167 if (orig_bin !=
NULL)
176 cell->orig_bin =
NULL;
◆ omtTestFreeDebug()
◆ omtTestFreeKeep()
◆ omtTestRealloc()
void omtTestRealloc |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
Definition at line 178 of file omtTestAlloc.c.
181 void* old_addr = cell->addr;
182 unsigned long old_spec = cell->spec;
183 omBin old_bin = cell->bin;
184 omBin old_orig_bin = cell->orig_bin;
185 size_t old_size =
GET_SIZE(old_spec);
189 size_t new_size =
GET_SIZE(new_spec);
215 new_orig_bin = new_bin;
222 else new_addr =
omReallocBin(old_addr, old_bin, new_bin);
287 else new_addr =
omRealloc0(old_addr, new_size);
294 new_addr =
omrealloc(old_addr, new_size);
298 else new_addr =
omRealloc(old_addr, new_size);
319 if (old_orig_bin !=
NULL)
326 old_size = real_old_size;
327 min_size = (new_size < old_size ? new_size : old_size);
334 if (
IS_ZERO(new_spec) && old_size < new_size)
338 cell->addr = new_addr;
339 cell->spec = new_spec;
341 cell->orig_bin = new_orig_bin;
◆ omtTestReallocDebug()
void omtTestReallocDebug |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ omtTestReallocKeep()
void omtTestReallocKeep |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ TestAddrContent()
void TestAddrContent |
( |
void * |
addr, |
|
|
unsigned long |
value, |
|
|
size_t |
size |
|
) |
| |
Definition at line 110 of file omtTest.c.
112 size_t sizeW = OM_ALIGN_SIZE(
size) >> LOG_SIZEOF_LONG;
115 if (!OM_IS_ALIGNED(addr))
118 "addr %p unaligned", addr);
122 for (
i=0;
i<sizeW;
i++)
124 if (((
unsigned long*)addr)[
i] != value)
127 "word %d modified: is %u should be %u",
i, ((
unsigned long*)addr)[
i], value);
◆ TestAddrContentEqual()
void TestAddrContentEqual |
( |
void * |
s1, |
|
|
void * |
s2, |
|
|
size_t |
size |
|
) |
| |
Definition at line 94 of file omtTest.c.
97 size_t sizeW = OM_ALIGN_SIZE(
size) >> LOG_SIZEOF_LONG;
99 for (
i=0;
i<sizeW;
i++)
101 if (((
unsigned long*)s1)[
i] != ((
unsigned long*)s2)[
i])
104 "s1[%u]==%d != s2[%u]==%d",
i, ((
unsigned long*)s1)[
i],
i, ((
unsigned long*)s2)[
i]);
◆ TestAlloc()
void TestAlloc |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ TestFree()
◆ TestRealloc()
void TestRealloc |
( |
omMemCell |
cell, |
|
|
unsigned long |
spec |
|
) |
| |
◆ cells
void * om_AlwaysKeptAddrs
void error(const char *fmt,...)
#define omTypeAlloc(type, addr, size)
void omtTestFree(omMemCell cell)
#define omTypeRealloc0AlignedSize
void omtTestAllocKeep(omMemCell cell, unsigned long spec)
#define omMemsetW(P1, W, L)
void TestAddrContentEqual(void *s1, void *s2, size_t size)
#define omRealloc0Aligned
#define IS_FREE_BINADDR(spec)
size_t omSizeOfAddr(const void *addr)
#define omGetSpecBin(size)
#define omTypeAlloc0Aligned
#define omReallocAlignedSize
#define omDebugBinAddrSize(addr, size)
#define omIsTrackAddr(addr)
void InitCellAddrContent(omMemCell cell)
#define omTypeReallocSize(o_addr, o_size, type, addr, size)
#define omTypeRealloc0Bin(o_addr, o_bin, type, addr, bin)
#define DO_FREE_CHECK(spec)
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
#define omTypeReallocAlignedSize
#define omTypeReallocBin(o_addr, o_bin, type, addr, bin)
#define omGetStickyBinOfBin(B)
#define omTypeRealloc(o_addr, type, addr, size)
#define omSmallSize2AlignedBin
#define omTypeRealloc0Aligned
void omtTestAllocDebug(omMemCell cell, unsigned long spec)
#define omDebugAddrAlignedBin
#define omrealloc0Size(addr, o_size, size)
#define omRealloc(addr, size)
#define omTypeAlloc0(type, addr, size)
omError_t om_InternalErrorStatus
const char * omError2Serror(omError_t error)
#define OM_MAX_BLOCK_SIZE
#define omDebugBinAddr(addr)
#define omTypeRealloc0(o_addr, type, addr, size)
#define omFreeSize(addr, size)
void omtTestFreeDebug(omMemCell cell)
#define omfreeSize(addr, size)
#define omFreeBinAddr(addr)
#define IS_FREE_SIZE(spec)
void omtTestDebug(omMemCell cell)
#define IS_SPEC_BIN(spec)
#define omrealloc(addr, size)
#define omTypeAlloc0Bin(type, addr, bin)
#define IS_STICKY_BIN(spec)
#define omTypeAllocBin(type, addr, bin)
#define omSmallSize2Bin(size)
#define omRealloc0AlignedSize
#define omReallocBin(o_addr, o_bin, bin)
#define omGetBinPageOfAddr(addr)
#define omTypeRealloc0Size(o_addr, o_size, type, addr, size)
#define IS_FREE_BIN(spec)
void TestAddrContent(void *addr, unsigned long value, size_t size)
#define omCheckList(ptr, level, report, OM_FLR_VAL)
void omtTestRealloc(omMemCell cell, unsigned long spec)
#define omDebugAddrSize(addr, size)
#define omrealloc0(addr, size)
omBin omtGetStickyBin(omBin bin)
#define omUnGetSpecBin(bin_ptr)
#define omGetAlignedSpecBin(size)
omMemCell omFindCell(struct LongSpec spec)
#define omCheckSortedList(ptr, what, level, report, OM_FLR_VAL)
#define omreallocSize(addr, o_size, size)
#define omDebugAddrAlignedSize
#define omRealloc0(addr, size)
#define omMergeStickyBinIntoBin(A, B)
omBinPageRegion_t * omBinPageRegion
#define omGetTopBinOfAddr(addr)
#define omRealloc0Size(addr, o_size, size)
void * omAddr_2_OutAddr(void *addr)
void omtTestFreeKeep(omMemCell cell)
void omtTestReallocKeep(omMemCell cell, unsigned long spec)
const CanonicalForm int s
#define omFindInGList(ptr, next, what, value)
#define omTypeAllocAligned
#define omTypeReallocAligned
#define omFreeBin(addr, bin)
#define omDebugAddr(addr)
void omtTestAlloc(omMemCell cell, unsigned long spec)
void omtTestReallocDebug(omMemCell cell, unsigned long spec)
#define omDebugAddrBin(addr, bin)
#define omRealloc0Bin(o_addr, o_bin, bin)
void TestAlloc(omMemCell cell, unsigned long spec)
#define omReallocSize(addr, o_size, size)