My Project
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
xalloc.h File Reference
#include <stdlib.h>
#include <string.h>
#include "omalloc/omConfig.h"

Go to the source code of this file.

Data Structures

struct  omInfo_t
 
struct  omOpts_t
 
struct  omBin_next_t
 
struct  omBin_t
 

Macros

#define OM_NDEBUG   1
 
#define XALLOC_BIN   1
 
#define REGISTER   register
 
#define omalloc(s)   malloc(s)
 
#define omAlloc(s)   malloc(s)
 
#define omfree(d)   free(d)
 
#define omFree(d)   free(d)
 
#define omFreeSize(d, s)   free(d)
 
#define omStrDup(s)   strdup(s)
 
#define omSizeWOfBin(bin_ptr)   (((bin_ptr->size)+SIZEOF_LONG-1)/SIZEOF_LONG)
 
#define omTypeAllocBin(T, P, B)   P=(T)omAllocBin(B)
 
#define omTypeAlloc0Bin(T, P, B)   P=(T)omAlloc0Bin(B)
 
#define omSizeWOfAddr(P)   (omSizeOfAddr(P)/SIZEOF_LONG)
 
#define omTypeAlloc(T, P, S)   P=(T)omAlloc(S)
 
#define omAlloc0Aligned(S)   omAlloc0(S)
 
#define omAllocAligned(S)   omAlloc(S)
 
#define omInitInfo()
 
#define omInitGetBackTrace()
 
#define omUpdateInfo()
 
#define omPrintStats(F)
 
#define omPrintInfo(F)
 
#define omPrintBinStats(F)
 
#define omMarkMemoryAsStatic()
 
#define omfreeSize(P, S)   free(P)
 
#define omFreeFunc   free
 
#define omFreeBinAddr(P)   free(P)
 
#define omrealloc(A, NS)   realloc(A,NS)
 
#define omreallocSize(A, OS, NS)   realloc(A,NS)
 
#define omrealloc0Size(A, OS, NS)   omRealloc0Size(A,OS,NS)
 
#define omRealloc(A, B)   realloc(A,B)
 
#define omReallocAligned(A, B)   realloc(A,B)
 
#define omReallocSize(A, B, C)   realloc(A,C)
 
#define omReallocAlignedSize(A, B)   realloc(A,B)
 
#define omMarkAsStaticAddr(A)
 
#define omMemcpyW(A, B, C)   memcpy(A,B,(C)*SIZEOF_LONG)
 
#define omGetStickyBinOfBin(B)   (B)
 
#define omTypeReallocAlignedSize   omTypeReallocSize
 
#define omTypeRealloc0AlignedSize   omTypeRealloc0Size
 
#define omRealloc0AlignedSize   omRealloc0Size
 
#define omMemDupAligned   omMemDup
 
#define omCheckIf(cond, test)   do {} while (0)
 
#define omCheckBinAddr(addr)   do {} while (0)
 
#define omCheckAddrBin(addr, bin)   do {} while (0)
 
#define omCheckBinAddrSize(addr, size)   do {} while (0)
 
#define omCheckAddrSize(addr, size)   do {} while (0)
 
#define omCheckAddr(addr)   do {} while (0)
 
#define omcheckAddrSize(addr, size)   do {} while (0)
 
#define omcheckAddr(addr)   do {} while (0)
 
#define omCheckBin(bin)   do {} while (0)
 
#define omCheckMemory()   do {} while (0)
 
#define omPrintCurrentBackTraceMax(A, B)   do {} while (0)
 
#define omPrintUsedTrackAddrs(F, max)   do {} while (0)
 
#define omPrintCurrentBackTrace(F)   do {} while (0)
 
#define omPrintUsedAddrs(F, max)   do {} while (0)
 
#define omdebugAddrSize(A, B)   do {} while (0)
 
#define omPrintAddrInfo(A, B, C)   do {} while (0)
 
#define omIsBinPageAddr(A)   (1)
 
#define omTestBinAddrSize(A, B, C)   (omError_NoError)
 
#define omTestList(ptr, level)   (omError_NoError)
 
#define omInitRet_2_Info(argv0)   do {} while (0)
 
#define omMergeStickyBinIntoBin(A, B)   do {} while (0)
 
#define X_OMALLOC
 
#define omMallocFunc   malloc
 
#define omFreeSizeFunc   omFreeSize
 
#define omReallocSizeFunc   realloc
 

Typedefs

typedef omBin_next_t * omBin_next
 
typedef omBin_t * omBin
 

Enumerations

enum  omError_e {
  omError_NoError = 0 , omError_Unknown , omError_InternalBug , omError_MemoryCorrupted ,
  omError_NullAddr , omError_InvalidRangeAddr , omError_FalseAddr , omError_FalseAddrOrMemoryCorrupted ,
  omError_WrongSize , omError_FreedAddr , omError_FreedAddrOrMemoryCorrupted , omError_WrongBin ,
  omError_UnknownBin , omError_NotBinAddr , omError_UnalignedAddr , omError_NullSizeAlloc ,
  omError_ListCycleError , omError_SortedListError , omError_KeptAddrListCorrupted , omError_FreePattern ,
  omError_BackPattern , omError_FrontPattern , omError_NotString , omError_StickyBin ,
  omError_MaxError , omError_NoError = 0 , omError_Unknown , omError_InternalBug ,
  omError_MemoryCorrupted , omError_NullAddr , omError_InvalidRangeAddr , omError_FalseAddr ,
  omError_FalseAddrOrMemoryCorrupted , omError_WrongSize , omError_FreedAddr , omError_FreedAddrOrMemoryCorrupted ,
  omError_WrongBin , omError_UnknownBin , omError_NotBinAddr , omError_UnalignedAddr ,
  omError_NullSizeAlloc , omError_ListCycleError , omError_SortedListError , omError_KeptAddrListCorrupted ,
  omError_FreePattern , omError_BackPattern , omError_FrontPattern , omError_NotString ,
  omError_StickyBin , omError_MaxError
}
 

Functions

static void * omAlloc0 (size_t s)
 
static void * omalloc0 (size_t s)
 
static void * omRealloc0Size (void *d, __attribute__((unused)) size_t os, size_t ns)
 
static void * omAllocBin (omBin b)
 
static void * omAlloc0Bin (omBin b)
 
static void omFreeBin (void *p, omBin b)
 
static omBin omGetSpecBin (size_t s)
 
static void omUnGetSpecBin (omBin *A)
 

Variables

struct omInfo_s om_Info
 
struct omOpts_s om_Opts
 
int om_sing_opt_show_mem
 

Data Structure Documentation

◆ omInfo_s

struct omInfo_s

Definition at line 10 of file omStats.h.

Data Fields
long AvailBytes
long AvailBytesFromValloc
long AvailBytesMalloc
long AvailPages
long CurrentBytesFromMalloc
long CurrentBytesFromValloc
long CurrentBytesMmap
long CurrentBytesSbrk
long CurrentBytesSystem
long CurrentRegionsAlloc
long InternalUsedBytesMalloc
long MaxBytesFromMalloc
long MaxBytesFromValloc
long MaxBytesMmap
long MaxBytesSbrk
long MaxBytesSystem
long MaxPages
long MaxRegionsAlloc
long UsedBytes
long UsedBytesFromValloc
long UsedBytesMalloc
long UsedPages

◆ omBin_next_s

struct omBin_next_s

Definition at line 112 of file xalloc.h.

Data Fields
omBin_next next

◆ omBin_s

struct omBin_s

Definition at line 36 of file omAllocPrivate.h.

Data Fields
omBin_next curr
omBinPage current_page
omBinPage last_page
long max_blocks
omBin next
size_t size
size_t sizeW
unsigned long sticky

Macro Definition Documentation

◆ OM_NDEBUG

#define OM_NDEBUG   1

Definition at line 10 of file xalloc.h.

◆ omalloc

#define omalloc (   s)    malloc(s)

Definition at line 84 of file xalloc.h.

◆ omAlloc

#define omAlloc (   s)    malloc(s)

Definition at line 85 of file xalloc.h.

◆ omAlloc0Aligned

#define omAlloc0Aligned (   S)    omAlloc0(S)

Definition at line 226 of file xalloc.h.

◆ omAllocAligned

#define omAllocAligned (   S)    omAlloc(S)

Definition at line 227 of file xalloc.h.

◆ omCheckAddr

#define omCheckAddr (   addr)    do {} while (0)

Definition at line 260 of file xalloc.h.

◆ omcheckAddr

#define omcheckAddr (   addr)    do {} while (0)

Definition at line 262 of file xalloc.h.

◆ omCheckAddrBin

#define omCheckAddrBin (   addr,
  bin 
)    do {} while (0)

Definition at line 257 of file xalloc.h.

◆ omCheckAddrSize

#define omCheckAddrSize (   addr,
  size 
)    do {} while (0)

Definition at line 259 of file xalloc.h.

◆ omcheckAddrSize

#define omcheckAddrSize (   addr,
  size 
)    do {} while (0)

Definition at line 261 of file xalloc.h.

◆ omCheckBin

#define omCheckBin (   bin)    do {} while (0)

Definition at line 263 of file xalloc.h.

◆ omCheckBinAddr

#define omCheckBinAddr (   addr)    do {} while (0)

Definition at line 256 of file xalloc.h.

◆ omCheckBinAddrSize

#define omCheckBinAddrSize (   addr,
  size 
)    do {} while (0)

Definition at line 258 of file xalloc.h.

◆ omCheckIf

#define omCheckIf (   cond,
  test 
)    do {} while (0)

Definition at line 255 of file xalloc.h.

◆ omCheckMemory

#define omCheckMemory ( )    do {} while (0)

Definition at line 264 of file xalloc.h.

◆ omdebugAddrSize

#define omdebugAddrSize (   A,
  B 
)    do {} while (0)

Definition at line 269 of file xalloc.h.

◆ omfree

#define omfree (   d)    free(d)

Definition at line 103 of file xalloc.h.

◆ omFree

#define omFree (   d)    free(d)

Definition at line 104 of file xalloc.h.

◆ omFreeBinAddr

#define omFreeBinAddr (   P)    free(P)

Definition at line 237 of file xalloc.h.

◆ omFreeFunc

#define omFreeFunc   free

Definition at line 236 of file xalloc.h.

◆ omFreeSize

#define omFreeSize (   d,
  s 
)    free(d)

Definition at line 105 of file xalloc.h.

◆ omfreeSize

#define omfreeSize (   P,
 
)    free(P)

Definition at line 235 of file xalloc.h.

◆ omFreeSizeFunc

#define omFreeSizeFunc   omFreeSize

Definition at line 285 of file xalloc.h.

◆ omGetStickyBinOfBin

#define omGetStickyBinOfBin (   B)    (B)

Definition at line 247 of file xalloc.h.

◆ omInitGetBackTrace

#define omInitGetBackTrace ( )

Definition at line 229 of file xalloc.h.

◆ omInitInfo

#define omInitInfo (   void)

Definition at line 228 of file xalloc.h.

◆ omInitRet_2_Info

#define omInitRet_2_Info (   argv0)    do {} while (0)

Definition at line 274 of file xalloc.h.

◆ omIsBinPageAddr

#define omIsBinPageAddr (   A)    (1)

Definition at line 271 of file xalloc.h.

◆ omMallocFunc

#define omMallocFunc   malloc

Definition at line 284 of file xalloc.h.

◆ omMarkAsStaticAddr

#define omMarkAsStaticAddr (   A)

Definition at line 245 of file xalloc.h.

◆ omMarkMemoryAsStatic

#define omMarkMemoryAsStatic ( )

Definition at line 234 of file xalloc.h.

◆ omMemcpyW

#define omMemcpyW (   A,
  B,
 
)    memcpy(A,B,(C)*SIZEOF_LONG)

Definition at line 246 of file xalloc.h.

◆ omMemDupAligned

#define omMemDupAligned   omMemDup

Definition at line 254 of file xalloc.h.

◆ omMergeStickyBinIntoBin

#define omMergeStickyBinIntoBin (   A,
  B 
)    do {} while (0)

Definition at line 275 of file xalloc.h.

◆ omPrintAddrInfo

#define omPrintAddrInfo (   A,
  B,
 
)    do {} while (0)

Definition at line 270 of file xalloc.h.

◆ omPrintBinStats

#define omPrintBinStats (   F)

Definition at line 233 of file xalloc.h.

◆ omPrintCurrentBackTrace

#define omPrintCurrentBackTrace (   F)    do {} while (0)

Definition at line 267 of file xalloc.h.

◆ omPrintCurrentBackTraceMax

#define omPrintCurrentBackTraceMax (   A,
  B 
)    do {} while (0)

Definition at line 265 of file xalloc.h.

◆ omPrintInfo

#define omPrintInfo (   F)

Definition at line 232 of file xalloc.h.

◆ omPrintStats

#define omPrintStats (   F)

Definition at line 231 of file xalloc.h.

◆ omPrintUsedAddrs

#define omPrintUsedAddrs (   F,
  max 
)    do {} while (0)

Definition at line 268 of file xalloc.h.

◆ omPrintUsedTrackAddrs

#define omPrintUsedTrackAddrs (   F,
  max 
)    do {} while (0)

Definition at line 266 of file xalloc.h.

◆ omRealloc

#define omRealloc (   A,
  B 
)    realloc(A,B)

Definition at line 241 of file xalloc.h.

◆ omrealloc

#define omrealloc (   A,
  NS 
)    realloc(A,NS)

Definition at line 238 of file xalloc.h.

◆ omRealloc0AlignedSize

#define omRealloc0AlignedSize   omRealloc0Size

Definition at line 253 of file xalloc.h.

◆ omrealloc0Size

#define omrealloc0Size (   A,
  OS,
  NS 
)    omRealloc0Size(A,OS,NS)

Definition at line 240 of file xalloc.h.

◆ omReallocAligned

#define omReallocAligned (   A,
  B 
)    realloc(A,B)

Definition at line 242 of file xalloc.h.

◆ omReallocAlignedSize

#define omReallocAlignedSize (   A,
  B 
)    realloc(A,B)

Definition at line 244 of file xalloc.h.

◆ omReallocSize

#define omReallocSize (   A,
  B,
 
)    realloc(A,C)

Definition at line 243 of file xalloc.h.

◆ omreallocSize

#define omreallocSize (   A,
  OS,
  NS 
)    realloc(A,NS)

Definition at line 239 of file xalloc.h.

◆ omReallocSizeFunc

#define omReallocSizeFunc   realloc

Definition at line 286 of file xalloc.h.

◆ omSizeWOfAddr

#define omSizeWOfAddr (   P)    (omSizeOfAddr(P)/SIZEOF_LONG)

Definition at line 223 of file xalloc.h.

◆ omSizeWOfBin

#define omSizeWOfBin (   bin_ptr)    (((bin_ptr->size)+SIZEOF_LONG-1)/SIZEOF_LONG)

Definition at line 124 of file xalloc.h.

◆ omStrDup

#define omStrDup (   s)    strdup(s)

Definition at line 107 of file xalloc.h.

◆ omTestBinAddrSize

#define omTestBinAddrSize (   A,
  B,
 
)    (omError_NoError)

Definition at line 272 of file xalloc.h.

◆ omTestList

#define omTestList (   ptr,
  level 
)    (omError_NoError)

Definition at line 273 of file xalloc.h.

◆ omTypeAlloc

#define omTypeAlloc (   T,
  P,
 
)    P=(T)omAlloc(S)

Definition at line 225 of file xalloc.h.

◆ omTypeAlloc0Bin

#define omTypeAlloc0Bin (   T,
  P,
  B 
)    P=(T)omAlloc0Bin(B)

Definition at line 153 of file xalloc.h.

◆ omTypeAllocBin

#define omTypeAllocBin (   T,
  P,
  B 
)    P=(T)omAllocBin(B)

Definition at line 152 of file xalloc.h.

◆ omTypeRealloc0AlignedSize

#define omTypeRealloc0AlignedSize   omTypeRealloc0Size

Definition at line 252 of file xalloc.h.

◆ omTypeReallocAlignedSize

#define omTypeReallocAlignedSize   omTypeReallocSize

Definition at line 251 of file xalloc.h.

◆ omUpdateInfo

#define omUpdateInfo (   void)

Definition at line 230 of file xalloc.h.

◆ REGISTER

#define REGISTER   register

Definition at line 27 of file xalloc.h.

◆ X_OMALLOC

#define X_OMALLOC

Definition at line 283 of file xalloc.h.

◆ XALLOC_BIN

#define XALLOC_BIN   1

Definition at line 12 of file xalloc.h.

Typedef Documentation

◆ omBin

typedef omBin_t* omBin

Definition at line 123 of file xalloc.h.

◆ omBin_next

typedef omBin_next_t* omBin_next

Definition at line 111 of file xalloc.h.

Enumeration Type Documentation

◆ omError_e

enum omError_e
Enumerator
omError_NoError 
omError_Unknown 
omError_InternalBug 
omError_MemoryCorrupted 
omError_NullAddr 
omError_InvalidRangeAddr 
omError_FalseAddr 
omError_FalseAddrOrMemoryCorrupted 
omError_WrongSize 
omError_FreedAddr 
omError_FreedAddrOrMemoryCorrupted 
omError_WrongBin 
omError_UnknownBin 
omError_NotBinAddr 
omError_UnalignedAddr 
omError_NullSizeAlloc 
omError_ListCycleError 
omError_SortedListError 
omError_KeptAddrListCorrupted 
omError_FreePattern 
omError_BackPattern 
omError_FrontPattern 
omError_NotString 
omError_StickyBin 
omError_MaxError 
omError_NoError 
omError_Unknown 
omError_InternalBug 
omError_MemoryCorrupted 
omError_NullAddr 
omError_InvalidRangeAddr 
omError_FalseAddr 
omError_FalseAddrOrMemoryCorrupted 
omError_WrongSize 
omError_FreedAddr 
omError_FreedAddrOrMemoryCorrupted 
omError_WrongBin 
omError_UnknownBin 
omError_NotBinAddr 
omError_UnalignedAddr 
omError_NullSizeAlloc 
omError_ListCycleError 
omError_SortedListError 
omError_KeptAddrListCorrupted 
omError_FreePattern 
omError_BackPattern 
omError_FrontPattern 
omError_NotString 
omError_StickyBin 
omError_MaxError 

Definition at line 193 of file xalloc.h.

194{
195 omError_NoError = 0,
220};
@ omError_WrongSize
Definition: xalloc.h:203
@ omError_ListCycleError
Definition: xalloc.h:211
@ omError_BackPattern
Definition: xalloc.h:215
@ omError_NullAddr
Definition: xalloc.h:199
@ omError_NullSizeAlloc
Definition: xalloc.h:210
@ omError_MaxError
Definition: xalloc.h:219
@ omError_FrontPattern
Definition: xalloc.h:216
@ omError_UnalignedAddr
Definition: xalloc.h:209
@ omError_MemoryCorrupted
Definition: xalloc.h:198
@ omError_FreedAddr
Definition: xalloc.h:204
@ omError_UnknownBin
Definition: xalloc.h:207
@ omError_FreedAddrOrMemoryCorrupted
Definition: xalloc.h:205
@ omError_NotString
Definition: xalloc.h:217
@ omError_SortedListError
Definition: xalloc.h:212
@ omError_KeptAddrListCorrupted
Definition: xalloc.h:213
@ omError_InternalBug
Definition: xalloc.h:197
@ omError_NotBinAddr
Definition: xalloc.h:208
@ omError_InvalidRangeAddr
Definition: xalloc.h:200
@ omError_FalseAddr
Definition: xalloc.h:201
@ omError_WrongBin
Definition: xalloc.h:206
@ omError_NoError
Definition: xalloc.h:195
@ omError_Unknown
Definition: xalloc.h:196
@ omError_StickyBin
Definition: xalloc.h:218
@ omError_FreePattern
Definition: xalloc.h:214
@ omError_FalseAddrOrMemoryCorrupted
Definition: xalloc.h:202

Function Documentation

◆ omAlloc0()

static void * omAlloc0 ( size_t  s)
inlinestatic

Definition at line 87 of file xalloc.h.

88{ void *d=malloc(s);memset(d,0,s); return d; }
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define malloc
Definition: omAllocFunc.c:12

◆ omalloc0()

static void * omalloc0 ( size_t  s)
inlinestatic

Definition at line 89 of file xalloc.h.

90{ if (s!=0) { void *d=malloc(s);memset(d,0,s); return d;} else return NULL; }
#define NULL
Definition: omList.c:12

◆ omAlloc0Bin()

static void * omAlloc0Bin ( omBin  b)
inlinestatic

Definition at line 135 of file xalloc.h.

136{
137 if (b->curr!=NULL)
138 {
139 omBin_next p=b->curr;
140 b->curr=p->next;
141 memset(p,0,b->size);
142 return p;
143 }
144 else return omAlloc0(b->size);
145}
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
#define omAlloc0(size)
Definition: omAllocDecl.h:211
omBin_next_t * omBin_next
Definition: xalloc.h:111

◆ omAllocBin()

static void * omAllocBin ( omBin  b)
inlinestatic

Definition at line 125 of file xalloc.h.

126{
127 if (b->curr!=NULL)
128 {
129 omBin_next p=b->curr;
130 b->curr=p->next;
131 return p;
132 }
133 else return omAlloc(b->size);
134}
#define omAlloc(s)
Definition: xalloc.h:85

◆ omFreeBin()

static void omFreeBin ( void *  p,
omBin  b 
)
inlinestatic

Definition at line 146 of file xalloc.h.

147{
148 *((void**) p) = b->curr;
149 b->curr=(omBin_next)p;
150}

◆ omGetSpecBin()

static omBin omGetSpecBin ( size_t  s)
inlinestatic

Definition at line 154 of file xalloc.h.

155{
156 omBin b=(omBin)omAlloc(sizeof(*b));
157 b->size=s;
158 b->curr=NULL;
159 return b;
160}
omBin_t * omBin
Definition: omStructs.h:12
omBin_t * omBin
Definition: xalloc.h:123

◆ omRealloc0Size()

static void * omRealloc0Size ( void *  d,
__attribute__((unused)) size_t  os,
size_t  ns 
)
inlinestatic

Definition at line 92 of file xalloc.h.

93{ if (d==NULL)
94 return omAlloc0(ns);
95 else
96 {
97 char *p=(char *)realloc(d,ns);
98 if (ns>os) memset(p+os,0,ns-os);
99 return (void*)p;
100 }
101}
#define realloc
Definition: omAllocFunc.c:16

◆ omUnGetSpecBin()

static void omUnGetSpecBin ( omBin A)
inlinestatic

Definition at line 161 of file xalloc.h.

162{
163 omBin_next p=(*A)->curr;
165 while(p!=NULL)
166 {
167 pp=p->next;
168 omFree(p);
169 p=pp;
170 }
171 (*A)->curr=NULL;
172 omFree(*A);
173}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
#define A
Definition: sirandom.c:24
#define omFree(d)
Definition: xalloc.h:104

Variable Documentation

◆ om_Info

struct omInfo_s om_Info
extern

Definition at line 16 of file omStats.c.

◆ om_Opts

struct omOpts_s om_Opts

Definition at line 25 of file omOpts.c.

◆ om_sing_opt_show_mem

int om_sing_opt_show_mem
extern