~ubuntu-branches/ubuntu/vivid/unrar-nonfree/vivid

« back to all changes in this revision

Viewing changes to suballoc.hpp

  • Committer: Package Import Robot
  • Author(s): Martin Meredith
  • Date: 2015-02-03 12:58:01 UTC
  • mfrom: (1.1.18) (5.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20150203125801-od6ev8cqy1er51vz
Tags: 1:5.2.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#if !defined(_SUBALLOC_H_)
8
8
#define _SUBALLOC_H_
9
9
 
10
 
const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
11
 
const int N_INDEXES=N1+N2+N3+N4;
12
 
 
13
 
#if defined(__GNUC__) && !defined(STRICT_ALIGNMENT_REQUIRED)
14
 
#define _PACK_ATTR __attribute__ ((packed))
 
10
#if defined(__GNUC__) && defined(ALLOW_MISALIGNED)
 
11
#define RARPPM_PACK_ATTR __attribute__ ((packed))
15
12
#else
16
 
#define _PACK_ATTR
 
13
#define RARPPM_PACK_ATTR
17
14
#endif /* defined(__GNUC__) */
18
15
 
19
 
#ifndef STRICT_ALIGNMENT_REQUIRED
 
16
#ifdef ALLOW_MISALIGNED
20
17
#pragma pack(1)
21
18
#endif
22
19
 
23
 
struct RAR_MEM_BLK 
 
20
struct RARPPM_MEM_BLK 
24
21
{
25
22
  ushort Stamp, NU;
26
 
  RAR_MEM_BLK* next, * prev;
27
 
  void insertAt(RAR_MEM_BLK* p) 
 
23
  RARPPM_MEM_BLK* next, * prev;
 
24
  void insertAt(RARPPM_MEM_BLK* p) 
28
25
  {
29
26
    next=(prev=p)->next;
30
27
    p->next=next->prev=this;
34
31
    prev->next=next;
35
32
    next->prev=prev;
36
33
  }
37
 
} _PACK_ATTR;
 
34
} RARPPM_PACK_ATTR;
38
35
 
39
 
#ifndef STRICT_ALIGNMENT_REQUIRED
 
36
#ifdef ALLOW_MISALIGNED
40
37
#ifdef _AIX
41
38
#pragma pack(pop)
42
39
#else
45
42
#endif
46
43
 
47
44
 
48
 
struct RAR_NODE
49
 
{
50
 
  RAR_NODE* next;
51
 
};
52
 
 
53
45
class SubAllocator
54
46
{
55
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
    {
 
53
      RAR_NODE* next;
 
54
    };
 
55
 
56
56
    inline void InsertNode(void* p,int indx);
57
57
    inline void* RemoveNode(int indx);
58
58
    inline uint U2B(int NU);
60
60
    uint GetUsedMemory();
61
61
    inline void GlueFreeBlocks();
62
62
    void* AllocUnitsRare(int indx);
63
 
    inline RAR_MEM_BLK* MBPtr(RAR_MEM_BLK *BasePtr,int Items);
 
63
    inline RARPPM_MEM_BLK* MBPtr(RARPPM_MEM_BLK *BasePtr,int Items);
64
64
 
65
65
    long SubAllocatorSize;
66
66
    byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;