gCAD3D 2.40
ut_mem.h
Go to the documentation of this file.
1 // ../ut/ut_mem.h
2 // ../ut/ut_mem.c
3 
4 
5 // max size for allocation on stack:
6 #define SPC_MAX_STK 32767
7 
8 
9  // ut_mem.o:
10  int MEM_swap__ (void *stru1, void* stru2, long strSiz);
11 
12 
13  int MEM_ins_rec (void *insPos, long movSiz, void *insDat, long insSiz);
14  int MEM_chg_rec (void *datStart, long *datSiz,
15  void *insDat, long insSiz,
16  void *delPos, long delSiz);
17  int MEM_ins_nrec (int *recNr, void *recTab,
18  int ipos, void *insDat, int insRecNr, int sizRec);
19  int MEM_del_nrec (int *recNr, void *recTab,
20  int ipos, int delRecNr, int sizRec);
21  int MEM_del_IndRec (int *recNr, void *recTab, int ipos);
22  int MEM_del_DbRec (int *recNr, void *recTab, int ipos);
23  int MEM_del_ShRec (int *recNr, void *recTab, int ipos);
24  void* MEM_ptr_mov (void *ptr, long dist);
25  int MEM_cmp__ (void *obj1, void *obj2, int size);
26 
27 
28 //----------------------------------------------------------------
30 #define MEM_cmp__ memcmp
31 
33 void MEM_swap_byte (char *c1, char *c2);
34 #define MEM_swap_byte(c1,c2){\
35  char _c3 = *(c1); *(c1) = *(c2); *(c2) = _c3;}
36 
38 void MEM_swap_short (short *i1, short *i2);
39 #define MEM_swap_short(i1,i2){\
40  short _i3 = *(i1); *(i1) = *(i2); *(i2) = _i3;}
41 
43 void MEM_swap_int (int *i1, int *i2);
44 #define MEM_swap_int(i1,i2){\
45  int _i3 = *(i1); *(i1) = *(i2); *(i2) = _i3;}
46 
48 void MEM_swap_2lg (long *i1, long *i2);
49 #define MEM_swap_2lg(i1,i2){\
50  long _i3 = *(i1); *(i1) = *(i2); *(i2) = _i3;}
51 
53 void MEM_swap_2db (double*, double*);
54 #define MEM_swap_2db(d1,d2){\
55  double _d3 = *(d1); *(d1) = *(d2); *(d2) = _d3;}
56 
58 void MEM_swap_2vp (void **v1, void **v2);
59 #define MEM_swap_2vp(v1,v2){\
60  void *_v3 = *(v1); *(v1) = *(v2); *(v2) = _v3;}
61 // void MEM_swap_2vp (void **p1, void **p2)
62 
63 // swap structs: MEM_swap__ ();
64 
70 #define MEM_ptr_mov(ptr,dist) ((char*)(ptr) + (dist))
71 
72 
81 void* MEM_alloc_tmp (int);
82 /*
83 #ifdef _MSC_VER
84 #define MEM_alloc_tmp(siz) _alloca(siz + 64)
85 //#define MEM_alloc_tmp(siz) alloca(siz)
86 #else
87 #define MEM_alloc_tmp(siz) alloca(siz)
88 #endif
89 */
90 #ifdef _MSC_VER
91 #define MEM_alloc_tmp(siz) _alloca(siz + 64)
92 //#define MEM_alloc_tmp(siz) alloca(siz)
93 #else
94 #define MEM_alloc_tmp(siz)\
95  alloca(siz);\
96  if(siz >= SPC_MAX_STK) printf("*** ERR MEM_alloc_tmp |%s| %d\n",__func__,siz);\
97  fflush(stdout)
98 #endif
99 
100 
102 int MEM_alloc_file (void**, long*, char*);
103 #define MEM_alloc_file(fBuf, fSiz, fNam)\
104  *fSiz = OS_FilSiz (fNam);\
105  *fBuf = (void*)MEM_alloc_tmp ((int)*fSiz)
106 
107 // #ifdef _MSC_VER
108 // #define MEM_alloc_file(fBuf, fSiz, fNam)\
109 // *fSiz = OS_FilSiz (fNam);\
110 // _alloca(*fSiz + 64)
111 // #else
112 // #define MEM_alloc_file(fBuf, fSiz, fNam)\
113 // *fSiz = OS_FilSiz (fNam);\
114 // alloca(*fSiz);
115 // #endif
116 
117 
118 
119 //=============== EOF ============================================
#define MEM_swap_2db(d1, d2)
Definition: ut_mem.h:54
#define MEM_swap_2lg(i1, i2)
Definition: ut_mem.h:49
int MEM_del_DbRec(int *recNr, void *recTab, int ipos)
Definition: ut_mem.c:600
#define MEM_swap_int(i1, i2)
Definition: ut_mem.h:44
int MEM_ins_nrec(int *recNr, void *recTab, int ipos, void *insDat, int insRecNr, int sizRec)
Definition: ut_mem.c:469
int MEM_del_nrec(int *recNr, void *recTab, int ipos, int delRecNr, int sizRec)
Definition: ut_mem.c:624
#define MEM_alloc_tmp(siz)
Definition: t1.c:81
#define MEM_cmp__
compare memoryspaces (n bytes); returns 0 for equal.
Definition: ut_mem.h:30
int MEM_del_ShRec(int *recNr, void *recTab, int ipos)
Definition: ut_mem.c:612
int MEM_ins_rec(void *insPos, long movSiz, void *insDat, long insSiz)
Definition: ut_mem.c:438
#define MEM_alloc_file(fBuf, fSiz, fNam)
Definition: ut_mem.h:103
#define MEM_ptr_mov(ptr, dist)
Definition: ut_mem.h:70
#define MEM_swap_short(i1, i2)
Definition: ut_mem.h:39
int MEM_swap__(void *stru1, void *stru2, long strSiz)
Definition: ut_mem.c:345
#define MEM_swap_2vp(v1, v2)
Definition: ut_mem.h:59
int MEM_del_IndRec(int *recNr, void *recTab, int ipos)
Definition: ut_mem.c:587
int MEM_chg_rec(void *datStart, long *datSiz, void *insDat, long insSiz, void *delPos, long delSiz)
Definition: ut_mem.c:519
#define MEM_swap_byte(c1, c2)
Definition: ut_mem.h:34