unrarsrc  6.1.7
About: unrar extracts, views and tests the contents of archives created with the RAR archiver.
  Fossies Dox: unrarsrc-6.1.7.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

suballoc.hpp
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of PPMd project *
3 * Written and distributed to public domain by Dmitry Shkarin 1997, *
4 * 1999-2000 *
5 * Contents: interface to memory allocation routines *
6 ****************************************************************************/
7#if !defined(_SUBALLOC_H_)
8#define _SUBALLOC_H_
9
10#if defined(__GNUC__) && defined(ALLOW_MISALIGNED)
11#define RARPPM_PACK_ATTR __attribute__ ((packed))
12#else
13#define RARPPM_PACK_ATTR
14#endif /* defined(__GNUC__) */
15
16#ifdef ALLOW_MISALIGNED
17#pragma pack(1)
18#endif
19
21{
25 {
26 next=(prev=p)->next;
27 p->next=next->prev=this;
28 }
29 void remove()
30 {
31 prev->next=next;
32 next->prev=prev;
33 }
35
36#ifdef ALLOW_MISALIGNED
37#ifdef _AIX
38#pragma pack(pop)
39#else
40#pragma pack()
41#endif
42#endif
43
44
46{
47 private:
48 static const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
49 static const int N_INDEXES=N1+N2+N3+N4;
50
51 struct RAR_NODE
52 {
54 };
55
56 inline void InsertNode(void* p,int indx);
57 inline void* RemoveNode(int indx);
58 inline uint U2B(int NU);
59 inline void SplitBlock(void* pv,int OldIndx,int NewIndx);
60 inline void GlueFreeBlocks();
61 void* AllocUnitsRare(int indx);
62 inline RARPPM_MEM_BLK* MBPtr(RARPPM_MEM_BLK *BasePtr,int Items);
63
68 public:
71 void Clean();
72 bool StartSubAllocator(int SASize);
73 void StopSubAllocator();
74 void InitSubAllocator();
75 inline void* AllocContext();
76 inline void* AllocUnits(int NU);
77 inline void* ExpandUnits(void* ptr,int OldNU);
78 inline void* ShrinkUnits(void* ptr,int OldNU,int NewNU);
79 inline void FreeUnits(void* ptr,int OldNU);
81
83};
84
85
86#endif /* !defined(_SUBALLOC_H_) */
void InsertNode(void *p, int indx)
Definition: suballoc.cpp:23
byte * HeapStart
Definition: suballoc.hpp:66
long SubAllocatorSize
Definition: suballoc.hpp:64
void Clean()
Definition: suballoc.cpp:17
byte * pText
Definition: suballoc.hpp:82
void * ExpandUnits(void *ptr, int OldNU)
Definition: suballoc.cpp:257
byte Units2Indx[128]
Definition: suballoc.hpp:65
void FreeUnits(void *ptr, int OldNU)
Definition: suballoc.cpp:292
uint U2B(int NU)
Definition: suballoc.cpp:38
void InitSubAllocator()
Definition: suballoc.cpp:106
byte * HeapEnd
Definition: suballoc.hpp:82
static const int N4
Definition: suballoc.hpp:48
struct RAR_NODE FreeList[N_INDEXES]
Definition: suballoc.hpp:67
byte * FakeUnitsStart
Definition: suballoc.hpp:82
byte * HiUnit
Definition: suballoc.hpp:66
long GetAllocatedMemory()
Definition: suballoc.hpp:80
static const int N1
Definition: suballoc.hpp:48
void * ShrinkUnits(void *ptr, int OldNU, int NewNU)
Definition: suballoc.cpp:272
RARPPM_MEM_BLK * MBPtr(RARPPM_MEM_BLK *BasePtr, int Items)
Definition: suballoc.cpp:49
void SplitBlock(void *pv, int OldIndx, int NewIndx)
Definition: suballoc.cpp:55
void StopSubAllocator()
Definition: suballoc.cpp:69
byte * LoUnit
Definition: suballoc.hpp:66
void * RemoveNode(int indx)
Definition: suballoc.cpp:30
bool StartSubAllocator(int SASize)
Definition: suballoc.cpp:79
void GlueFreeBlocks()
Definition: suballoc.cpp:168
byte Indx2Units[N_INDEXES]
Definition: suballoc.hpp:65
static const int N2
Definition: suballoc.hpp:48
byte * UnitsStart
Definition: suballoc.hpp:82
void * AllocContext()
Definition: suballoc.cpp:247
static const int N3
Definition: suballoc.hpp:48
void * AllocUnitsRare(int indx)
Definition: suballoc.cpp:201
static const int N_INDEXES
Definition: suballoc.hpp:49
void * AllocUnits(int NU)
Definition: suballoc.cpp:233
byte GlueCount
Definition: suballoc.hpp:65
unsigned int uint
Definition: rartypes.hpp:8
uint16_t ushort
Definition: rartypes.hpp:7
void remove()
Definition: suballoc.hpp:29
RARPPM_MEM_BLK * next
Definition: suballoc.hpp:23
void insertAt(RARPPM_MEM_BLK *p)
Definition: suballoc.hpp:24
RARPPM_MEM_BLK * prev
Definition: suballoc.hpp:23
ushort Stamp
Definition: suballoc.hpp:22
#define RARPPM_PACK_ATTR
Definition: suballoc.hpp:13