gCAD3D 2.35
ut_memTab.h
Go to the documentation of this file.
1 /* MemTab 2003-05-20 franz.reiter@cadcam.co.at
2 
3 */
7 // see also ../ut/ut_memTab.c
8 
21 #define def_MemTab(vTyp1)\
22  typedef struct {vTyp1 *data; int rMax, rNr, rSiz;\
23  unsigned char typ, incSiz, use, spcTyp;}
24 
26 #define typedef_MemTab(vTyp1)\
27  def_MemTab(vTyp1) MemTab_##vTyp1
28 
30 #define MemTab(vTyp1) MemTab_##vTyp1
31 // #define MemTab(vTyp1) (MemTab_##vTyp1) = { ((void *)0), -1, -1}
32 
33 // #define MemTab_empty {NULL, 0, 0, 0, ' ',' ',' ',' '}
34 #define MemTab_empty {NULL, 0, 0, 0}
35 
37 def_MemTab(void) MemTab;
38 
39 
40 
41 //================================================================
42 // prototypes:
43 int MEMTAB_IND (MemTab*);
44 int MEMTAB_MAX (MemTab*);
45 void *MEMTAB__ (MemTab*, int);
46 void *MEMTAB_DAT (MemTab*);
47 void *MEMTAB_POS (MemTab*);
48 int MEMTAB_IND_POS (MemTab*, void*);
49 
50 
51 //================================================================
52 // inline functions:
53 
54 // MEMTAB__ get pointer to data-record from index
55 #define MEMTAB__(mtb,irec)\
56  (&((mtb)->data[irec]))
57 
58 // MEMTAB_IND get index (pointer to next free = nr of used) INLINE
59 #define MEMTAB_IND(mtb)\
60  ((mtb)->rNr)
61 
62 // MEMTAB_MAX get size INLINE
63 #define MEMTAB_MAX(mtb)\
64  ((mtb)->rSiz)
65 
66 // MEMTAB_DAT get data-record complete INLINE
67 #define MEMTAB_DAT(mtb)\
68  ((mtb)->data)
69 
70 
71 // MEMTAB_POS get position of next data-record INLINE
72 // DOES NOT WORK IF data=NULL: use MemTab_check before.
73 // Example:
74 // // check for space for 4 points
75 // MemTab_check (pmt, &l1, 4);
76 // // get pointer to data
77 // pa = MEMTAB_POS (pmt);
78 // // save point-data
79 // MemTab_sav (pmt, &l1, points, 4);
80 // // pa now is adress of points
81 #define MEMTAB_POS(mtb)\
82  (&((mtb)->data[(mtb)->rNr]))
83 
84 
85 // MEMTAB_IND_POS get record-index from position INLINE
86 #define MEMTAB_IND_POS(mtb,pos)\
87  (((char*)pos - (char*)(mtb)->data) / (mtb)->rSiz)
88 
89 // EOF
#define MEMTAB_DAT(mtb)
Definition: ut_memTab.h:67
#define MEMTAB_IND(mtb)
Definition: ut_memTab.h:59
#define MEMTAB_IND_POS(mtb, pos)
Definition: ut_memTab.h:86
#define MemTab(vTyp1)
template for the typename:
Definition: ut_memTab.h:30
#define MEMTAB_POS(mtb)
Definition: ut_memTab.h:81
#define MEMTAB_MAX(mtb)
Definition: ut_memTab.h:63
#define def_MemTab(vTyp1)
Definition: ut_memTab.h:21
#define MEMTAB__(mtb, irec)
Definition: ut_memTab.h:55