Loading...
Searching...
No Matches
omtTestAlloc.c File Reference
`#include "omtTest.h"`
`#include "omalloc.h"`

Go to the source code of this file.

## Macros

#define | omSmallSize2AlignedBin omSmallSize2Bin
#define | DO_STRDUP(l)

## Functions

void | omtTestAlloc (omMemCell cell, unsigned long spec)
void | omtTestFree (omMemCell cell)
void | omtTestRealloc (omMemCell cell, unsigned long new_spec)
void | omtTestDup (omMemCell cell, unsigned long spec)

## Macro Definition Documentation

## DO_STRDUP

#define DO_STRDUP | ( |  | l | ) |

Value:
(l & 1)
l
int l
Definition cfEzgcd.cc:100

Definition at line 347 of file omtTestAlloc.c.

## omSmallSize2AlignedBin

#define omSmallSize2AlignedBin omSmallSize2Bin

Definition at line 29 of file omtTestAlloc.c.

## Function Documentation

## omtTestAlloc()

void omtTestAlloc | ( | omMemCell | cell,
|  | unsigned long | spec )

Definition at line 33 of file omtTestAlloc.c.

{
size_t size = GET_SIZE(spec);
void* addr;
omBin bin = NULL;
omBin orig_bin = NULL;
if (IS_BIN(spec) && (size <= OM_MAX_BLOCK_SIZE || IS_SPEC_BIN(spec)))
{
if (IS_SPEC_BIN(spec))
{
if (IS_ALIGNED(spec))
bin = omGetAlignedSpecBin(size);
else
bin = omGetSpecBin(size);
}
else
{
if (IS_ALIGNED(spec))
bin = omSmallSize2AlignedBin(size);
else
bin = omSmallSize2Bin(size);
}
if (IS_STICKY_BIN(spec))
{
orig_bin = bin;
bin = omtGetStickyBin(bin);
}
if (IS_INLINE(spec))
{
if (IS_ZERO(spec))
addr = omAlloc0Bin(bin);
else
addr = omAllocBin(bin);
}
else
{
if (IS_ZERO(spec))
omTypeAlloc0Bin(void*, addr, bin);
else
omTypeAllocBin(void*, addr, bin);
}
}
else
{
if (IS_INLINE(spec))
{
if (IS_ZERO(spec))
{
if (IS_ALIGNED(spec))
{
if (IS_SLOPPY(spec))
addr = omalloc0(size);
else
addr = omAlloc0Aligned(size);
}
else
addr = omAlloc0(size);
}
else
{
if (IS_ALIGNED(spec))
{
if (IS_SLOPPY(spec))
addr = omalloc(size);
else
addr = omAllocAligned(size);
}
else
addr = omAlloc(size);
}
}
else
{
if (IS_ZERO(spec))
{
if (IS_ALIGNED(spec))
omTypeAlloc0Aligned(void*, addr, size);
else
omTypeAlloc0(void*, addr, size);
}
else
{
if (IS_ALIGNED(spec))
omTypeAllocAligned(void*, addr, size);
else
omTypeAlloc(void*, addr, size);
}
}
}
cell->addr = addr;
cell->bin = bin;
cell->orig_bin = orig_bin;
cell->spec = spec;
InitCellAddrContent(cell);
omtTestDebug(cell);
}
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
omTypeAlloc0Bin
#define omTypeAlloc0Bin(type, addr, bin)
Definition omAllocDecl.h:204
omAlloc0Aligned
#define omAlloc0Aligned
Definition omAllocDecl.h:274
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omTypeAllocBin
#define omTypeAllocBin(type, addr, bin)
Definition omAllocDecl.h:203
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition omAllocDecl.h:206
omTypeAlloc0
#define omTypeAlloc0(type, addr, size)
Definition omAllocDecl.h:209
omalloc0
#define omalloc0(size)
Definition omAllocDecl.h:229
omalloc
#define omalloc(size)
Definition omAllocDecl.h:228
omTypeAlloc0Aligned
#define omTypeAlloc0Aligned
Definition omAllocDecl.h:272
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
omTypeAlloc
#define omTypeAlloc(type, addr, size)
Definition omAllocDecl.h:208
omTypeAllocAligned
#define omTypeAllocAligned
Definition omAllocDecl.h:271
omAllocAligned
#define omAllocAligned
Definition omAllocDecl.h:273
omSmallSize2Bin
#define omSmallSize2Bin(size)
Definition omAllocPrivate.h:211
omGetSpecBin
#define omGetSpecBin(size)
Definition omBin.h:11
omGetAlignedSpecBin
#define omGetAlignedSpecBin(size)
Definition omBin.h:10
NULL
#define NULL
Definition omList.c:12
omBin
omBin_t * omBin
Definition omStructs.h:12
OM_MAX_BLOCK_SIZE
#define OM_MAX_BLOCK_SIZE
Definition omTables.c:31
omSmallSize2AlignedBin
#define omSmallSize2AlignedBin
Definition omtTestAlloc.c:29
omtGetStickyBin
omBin omtGetStickyBin(omBin bin)
Definition omtTest.c:275
omtTestDebug
void omtTestDebug(omMemCell cell)
Definition omtTest.c:36
InitCellAddrContent
void InitCellAddrContent(omMemCell cell)
Definition omtTest.c:130
IS_SPEC_BIN
#define IS_SPEC_BIN(spec)
Definition omtTest.h:56
IS_STICKY_BIN
#define IS_STICKY_BIN(spec)
Definition omtTest.h:49
IS_ALIGNED
#define IS_ALIGNED(spec)
Definition omtTest.h:53
IS_BIN
#define IS_BIN(spec)
Definition omtTest.h:55
IS_SLOPPY
#define IS_SLOPPY(spec)
Definition omtTest.h:88
IS_ZERO
#define IS_ZERO(spec)
Definition omtTest.h:54
IS_INLINE
#define IS_INLINE(spec)
Definition omtTest.h:57
GET_SIZE
#define GET_SIZE(spec)
Definition omtTest.h:51

## omtTestDup()

void omtTestDup | ( | omMemCell | cell,
|  | unsigned long | spec )

Definition at line 348 of file omtTestAlloc.c.

{
omtTestDebug(cell);
if (DO_STRDUP(spec))
{
size_t size = omSizeOfAddr(cell->addr);
void* new_addr;
memset(cell->addr, 'a', size - 1);
((char*) cell->addr)[size-1] = '\0';
new_addr = omStrDup(cell->addr);
TestAddrContentEqual(new_addr, cell->addr, size);
omFree(new_addr);
InitCellAddrContent(cell);
}
else
{
void* new_addr = omMemDup(cell->addr);
TestAddrContentEqual(new_addr, cell->addr, omSizeOfAddr(cell->addr));
omFree(new_addr);
new_addr = omMemDupAligned(cell->addr);
TestAddrContentEqual(new_addr, cell->addr, omSizeOfAddr(cell->addr));
omDebugAddrAlignedSize(new_addr, omSizeOfAddr(cell->addr));
omFree(new_addr);
}
}
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omDebugAddrAlignedSize
#define omDebugAddrAlignedSize
Definition omAllocDecl.h:292
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omMemDup
#define omMemDup(s)
Definition omAllocDecl.h:264
omMemDupAligned
#define omMemDupAligned
Definition omAllocDecl.h:286
omSizeOfAddr
size_t omSizeOfAddr(const void *addr)
Definition omAllocSystem.c:110
DO_STRDUP
#define DO_STRDUP(l)
Definition omtTestAlloc.c:347
TestAddrContentEqual
void TestAddrContentEqual(void *s1, void *s2, size_t size)
Definition omtTest.c:90

## omtTestFree()

void omtTestFree | ( | omMemCell | cell | ) |

Definition at line 135 of file omtTestAlloc.c.

{
void* addr = cell->addr;
unsigned long spec = cell->spec;
omBin bin = cell->bin;
omBin orig_bin = cell->orig_bin;
size_t size = GET_SIZE(spec);
omtTestDebug(cell);
if (IS_FREE_SIZE(spec))
{
if (IS_SLOPPY(spec))
omfreeSize(addr, size);
else
omFreeSize(addr, size);
}
else if (bin != NULL && IS_FREE_BIN(spec))
omFreeBin(addr, bin);
else if (IS_FREE_BINADDR(spec) && (bin != NULL) && (size <= OM_MAX_BLOCK_SIZE))
{
omFreeBinAddr(addr);
}
else
{
if (IS_SLOPPY(spec))
omfree(addr);
else
omFree(addr);
}
if (bin != NULL && IS_SPEC_BIN(spec))
{
if (orig_bin != NULL)
omUnGetSpecBin(&orig_bin);
else
omUnGetSpecBin(&bin);
}
cell->addr = NULL;
cell->spec = 0;
cell->bin = NULL;
cell->orig_bin = NULL;
}
omfree
#define omfree(addr)
Definition omAllocDecl.h:237
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
omFreeBinAddr
#define omFreeBinAddr(addr)
Definition omAllocDecl.h:258
omfreeSize
#define omfreeSize(addr, size)
Definition omAllocDecl.h:236
omUnGetSpecBin
#define omUnGetSpecBin(bin_ptr)
Definition omBin.h:14
IS_FREE_BINADDR
#define IS_FREE_BINADDR(spec)
Definition omtTest.h:89
IS_FREE_SIZE
#define IS_FREE_SIZE(spec)
Definition omtTest.h:86
IS_FREE_BIN
#define IS_FREE_BIN(spec)
Definition omtTest.h:87

## omtTestRealloc()

void omtTestRealloc | ( | omMemCell | cell,
|  | unsigned long | new_spec )

Definition at line 180 of file omtTestAlloc.c.

{
void* old_addr = cell->addr;
unsigned long old_spec = cell->spec;
omBin old_bin = cell->bin;
omBin old_orig_bin = cell->orig_bin;
size_t old_size = GET_SIZE(old_spec);
void* new_addr;
omBin new_bin = NULL;
omBin new_orig_bin = NULL;
size_t new_size = GET_SIZE(new_spec);
size_t real_old_size = omSizeOfAddr(old_addr);
size_t min_size;
omtTestDebug(cell);
if (old_bin != NULL && IS_FREE_BIN(old_spec) &&
IS_BIN(new_spec) && ((new_size <= OM_MAX_BLOCK_SIZE) || IS_SPEC_BIN(new_spec)))
{
if (IS_SPEC_BIN(new_spec))
{
if (IS_ALIGNED(new_spec))
new_bin = omGetAlignedSpecBin(new_size);
else
new_bin = omGetSpecBin(new_size);
}
else
{
if (IS_ALIGNED(new_spec))
new_bin = omSmallSize2AlignedBin(new_size);
else
new_bin = omSmallSize2Bin(new_size);
}
if (IS_STICKY_BIN(new_spec))
{
new_orig_bin = new_bin;
new_bin = omtGetStickyBin(new_bin);
}
if (IS_INLINE(new_spec))
{
if (IS_ZERO(new_spec)) new_addr = omRealloc0Bin(old_addr, old_bin, new_bin);
else new_addr = omReallocBin(old_addr, old_bin, new_bin);
}
else
{
if (IS_ZERO(new_spec)) omTypeRealloc0Bin(old_addr, old_bin, void*, new_addr, new_bin);
else omTypeReallocBin(old_addr, old_bin, void*, new_addr, new_bin);
}
}
else
{
if (IS_FREE_SIZE(old_spec))
{
if (IS_INLINE(new_spec))
{
if (IS_ZERO(new_spec))
{
if (IS_ALIGNED(new_spec))
{
if (IS_SLOPPY(new_spec))
new_addr = omrealloc0Size(old_addr, old_size, new_size);
else
new_addr = omRealloc0AlignedSize(old_addr, old_size, new_size);
}
else
new_addr = omRealloc0Size(old_addr, old_size, new_size);
}
else
{
if (IS_ALIGNED(new_spec))
{
if (IS_SLOPPY(new_spec))
new_addr = omreallocSize(old_addr, old_size, new_size);
else
new_addr = omReallocAlignedSize(old_addr, old_size, new_size);
}
else new_addr = omReallocSize(old_addr, old_size, new_size);
}
}
else
{
if (IS_ZERO(new_spec))
{
if (IS_ALIGNED(new_spec)) omTypeRealloc0AlignedSize(old_addr, old_size, void*, new_addr, new_size);
else omTypeRealloc0Size(old_addr, old_size, void*, new_addr, new_size);
}
else
{
if (IS_ALIGNED(new_spec)) omTypeReallocAlignedSize(old_addr, old_size, void*, new_addr, new_size);
else omTypeReallocSize(old_addr, old_size, void*, new_addr, new_size);
}
}
}
else
{
if (IS_INLINE(new_spec))
{
if (IS_ZERO(new_spec))
{
if (IS_ALIGNED(new_spec))
{
if (IS_SLOPPY(new_spec))
new_addr = omrealloc0(old_addr, new_size);
else
new_addr = omRealloc0Aligned(old_addr, new_size);
}
else new_addr = omRealloc0(old_addr, new_size);
}
else
{
if (IS_ALIGNED(new_spec))
{
if (IS_SLOPPY(new_spec))
new_addr = omrealloc(old_addr, new_size);
else
new_addr = omReallocAligned(old_addr, new_size);
}
else new_addr = omRealloc(old_addr, new_size);
}
}
else
{
if (IS_ZERO(new_spec))
{
if (IS_ALIGNED(new_spec)) omTypeRealloc0Aligned(old_addr, void*, new_addr, new_size);
else omTypeRealloc0(old_addr, void*, new_addr, new_size);
}
else
{
if (IS_ALIGNED(new_spec)) omTypeReallocAligned(old_addr, void*, new_addr, new_size);
else omTypeRealloc(old_addr, void*, new_addr, new_size);
}
}
}
}
if (old_bin != NULL && IS_SPEC_BIN(old_spec))
{
if (old_orig_bin != NULL)
omUnGetSpecBin(&old_orig_bin);
else
omUnGetSpecBin(&old_bin);
}
new_size = omSizeOfAddr(new_addr);
old_size = real_old_size;
min_size = (new_size < old_size ? new_size : old_size);
if (IS_ZERO(old_spec) && IS_ZERO(new_spec))
TestAddrContent(new_addr, 0, new_size);
else
{
TestAddrContent(new_addr, (IS_ZERO(old_spec) ? 0 : old_spec), min_size);
if (IS_ZERO(new_spec) && old_size < new_size)
TestAddrContent((char *)new_addr + old_size, 0, new_size - old_size);
}
cell->addr = new_addr;
cell->spec = new_spec;
cell->bin = new_bin;
cell->orig_bin = new_orig_bin;
InitCellAddrContent(cell);
omtTestDebug(cell);
}
omrealloc
#define omrealloc(addr, size)
Definition omAllocDecl.h:233
omTypeReallocAlignedSize
#define omTypeReallocAlignedSize
Definition omAllocDecl.h:276
omTypeRealloc0
#define omTypeRealloc0(o_addr, type, addr, size)
Definition omAllocDecl.h:224
omTypeRealloc0Size
#define omTypeRealloc0Size(o_addr, o_size, type, addr, size)
Definition omAllocDecl.h:219
omRealloc0AlignedSize
#define omRealloc0AlignedSize
Definition omAllocDecl.h:279
omrealloc0Size
#define omrealloc0Size(addr, o_size, size)
Definition omAllocDecl.h:232
omRealloc0Aligned
#define omRealloc0Aligned
Definition omAllocDecl.h:284
omreallocSize
#define omreallocSize(addr, o_size, size)
Definition omAllocDecl.h:231
omReallocSize
#define omReallocSize(addr, o_size, size)
Definition omAllocDecl.h:220
omReallocAligned
#define omReallocAligned
Definition omAllocDecl.h:283
omTypeRealloc0AlignedSize
#define omTypeRealloc0AlignedSize
Definition omAllocDecl.h:277
omrealloc0
#define omrealloc0(addr, size)
Definition omAllocDecl.h:234
omRealloc0Bin
#define omRealloc0Bin(o_addr, o_bin, bin)
Definition omAllocDecl.h:216
omTypeRealloc0Bin
#define omTypeRealloc0Bin(o_addr, o_bin, type, addr, bin)
Definition omAllocDecl.h:214
omRealloc
#define omRealloc(addr, size)
Definition omAllocDecl.h:225
omReallocAlignedSize
#define omReallocAlignedSize
Definition omAllocDecl.h:278
omTypeRealloc0Aligned
#define omTypeRealloc0Aligned
Definition omAllocDecl.h:282
omReallocBin
#define omReallocBin(o_addr, o_bin, bin)
Definition omAllocDecl.h:215
omRealloc0Size
#define omRealloc0Size(addr, o_size, size)
Definition omAllocDecl.h:221
omTypeReallocAligned
#define omTypeReallocAligned
Definition omAllocDecl.h:281
omRealloc0
#define omRealloc0(addr, size)
Definition omAllocDecl.h:226
omTypeReallocSize
#define omTypeReallocSize(o_addr, o_size, type, addr, size)
Definition omAllocDecl.h:218
omTypeReallocBin
#define omTypeReallocBin(o_addr, o_bin, type, addr, bin)
Definition omAllocDecl.h:213
omTypeRealloc
#define omTypeRealloc(o_addr, type, addr, size)
Definition omAllocDecl.h:223
TestAddrContent
void TestAddrContent(void *addr, unsigned long value, size_t size)
Definition omtTest.c:106