gCAD3D 2.35
ut_mem.h File Reference

Go to the source code of this file.

Macros

#define MEM_cmp__   memcmp
 compare memoryspaces (n bytes); returns 0 for equal. More...
 
#define MEM_swap_short(i1, i2)
 
#define MEM_swap_int(i1, i2)
 
#define MEM_swap_2lg(i1, i2)
 
#define MEM_swap_2db(d1, d2)
 
#define MEM_swap_2vp(v1, v2)
 
#define MEM_ptr_mov(ptr, dist)   ((char*)(ptr) + (dist))
 
#define MEM_alloc_tmp(siz)   alloca(siz)
 
#define MEM_alloc_file(fBuf, fSiz, fNam)
 

Functions

int MEM_swap__ (void *stru1, void *stru2, long strSiz)
 
int MEM_ins_rec (void *insPos, long movSiz, void *insDat, long insSiz)
 
int MEM_chg_rec (void *datStart, long *datSiz, void *insDat, long insSiz, void *delPos, long delSiz)
 
int MEM_ins_nrec (int *recNr, void *recTab, int ipos, void *insDat, int insRecNr, int sizRec)
 
int MEM_del_nrec (int *recNr, void *recTab, int ipos, int delRecNr, int sizRec)
 
int MEM_del_IndRec (int *recNr, void *recTab, int ipos)
 
int MEM_del_DbRec (int *recNr, void *recTab, int ipos)
 
void * MEM_ptr_mov (void *ptr, long dist)
 
int MEM_cmp__ (void *obj1, void *obj2, int size)
 
void MEM_swap_short (short *i1, short *i2)
 swap 2 shorts More...
 
void MEM_swap_int (int *i1, int *i2)
 swap 2 ints More...
 
void MEM_swap_2lg (long *i1, long *i2)
 swap 2 longs More...
 
void MEM_swap_2db (double *, double *)
 swap 2 doubles More...
 
void MEM_swap_2vp (void **v1, void **v2)
 swap 2 pointers (void*) More...
 
void * MEM_alloc_tmp (int)
 
int MEM_alloc_file (void **, long *, char *)
 UME_TMP_FILE allocate temp.memspace for file. More...
 

Macro Definition Documentation

#define MEM_cmp__   memcmp

compare memoryspaces (n bytes); returns 0 for equal.

#define MEM_swap_short (   i1,
  i2 
)
Value:
{\
short _i3 = *(i1); *(i1) = *(i2); *(i2) = _i3;}
#define MEM_swap_int (   i1,
  i2 
)
Value:
{\
int _i3 = *(i1); *(i1) = *(i2); *(i2) = _i3;}
#define MEM_swap_2lg (   i1,
  i2 
)
Value:
{\
long _i3 = *(i1); *(i1) = *(i2); *(i2) = _i3;}
#define MEM_swap_2db (   d1,
  d2 
)
Value:
{\
double _d3 = *(d1); *(d1) = *(d2); *(d2) = _d3;}
#define MEM_swap_2vp (   v1,
  v2 
)
Value:
{\
void *_v3 = *(v1); *(v1) = *(v2); *(v2) = _v3;}
#define MEM_ptr_mov (   ptr,
  dist 
)    ((char*)(ptr) + (dist))
MEM_ptr_mov move a pointer <dist> bytes
Example:
ptr = MEM_ptr_mov (ptr, 16); // move ptr 16 bytes in memory
#define MEM_alloc_tmp (   siz)    alloca(siz)
#define MEM_alloc_file (   fBuf,
  fSiz,
  fNam 
)
Value:
*fSiz = OS_FilSiz (fNam);\
*fBuf = (void*)MEM_alloc_tmp (*fSiz)
long OS_FilSiz(char *filnam)
Definition: doxy_help1.c:497
#define MEM_alloc_tmp(siz)
Definition: ut_mem.h:73

Function Documentation

int MEM_swap__ ( void *  stru1,
void *  stru2,
long  strSiz 
)
MEM_swap__ 2 structs vertauschen
MEM_swap__(&p1, &p2, sizeof(Point));
int MEM_ins_rec ( void *  insPos,
long  movSiz,
void *  insDat,
long  insSiz 
)
MEM_ins_rec insert data into mem
insDat data to insert
insSiz size of insDat
insPos where to insert
movSiz how much bytes to move from insPos to insPos+insSiz
int MEM_chg_rec ( void *  datStart,
long *  datSiz,
void *  insDat,
long  insSiz,
void *  delPos,
long  delSiz 
)
MEM_chg_rec change a record in mem (change line)
Input:
datStart Startposition des Datenblock
datSiz Size Datenblock (zB ex strlen)
insDat data to insert (len = insSiz)
insSiz size of insDat
delPos Position of old record (delete) and new record (insert)
delSiz how much bytes to delete at Pos delPos
Output:
datSiz wird korrigiert
strcpy(cbuf, "1234567890"); l1 = strlen(cbuf);
MEM_chg_rec (cbuf, &l1, "AAA", 3, &cbuf[4], 1); // 5 -> AAA
strcpy(cbuf, "1234567890"); l1 = strlen(cbuf);
MEM_chg_rec (cbuf, &l1, "A", 1, &cbuf[4], 3); // 567 -> A
see also MEM_chg_str
int MEM_ins_nrec ( int *  recNr,
void *  recTab,
int  ipos,
void *  insDat,
int  insRecNr,
int  sizRec 
)
insert records into table.
insert data BEFORE Record with index ipos.
insert dataBlock insDat BEFORE dataRecord Nr ipos into Table recTab
recTab consists of *recNr records of size sizRec
Input/Output:
*recNr nr of records of table recTab;
after exit recNr += insRecNr
recTab table with *recNr records; each with a size of sizRec bytes.
after exit record nr ipos is the firsdt record of insDat ..
Input:
ipos index in recTab of the first inserted record of insDat
insDat data to insert; size = sizRec * insRecNr
insRecNr nr of records to insert
sizRec size of records (of recTab and insDat)
Example insert 1 point p31 into 3. position (index nr 2) of pTab:
MEM_ins_nrec (&recNr, pTab, 2, &p31, 1, sizeof(Point));
int MEM_del_nrec ( int *  recNr,
void *  recTab,
int  ipos,
int  delRecNr,
int  sizRec 
)
delete <delRecNr> records from table.
first Record to delete has index ipos.
recTab consists of *recNr records of size sizRec
Input/Output:
*recNr nr of records of table recTab;
after exit recNr -= delRecNr
recTab table with *recNr records; each with a size of sizRec bytes.
Input:
ipos index in recTab of the first record to delete ..
delRecNr nr of records to delete
sizRec size of records of recTab
Example delete the 3. point (index nr 2) out of pTab:
MEM_del_nrec (&pNr, pTab, 2, 1, sizeof(Point));
int MEM_del_IndRec ( int *  recNr,
void *  recTab,
int  ipos 
)
MEM_del_IndRec delete 1 integer in intArray
recNr is decremented
int MEM_del_DbRec ( int *  recNr,
void *  recTab,
int  ipos 
)
MEM_del_DbRec delete 1 double in double-Array
recNr is decremented
void* MEM_ptr_mov ( void *  ptr,
long  dist 
)
int MEM_cmp__ ( void *  obj1,
void *  obj2,
int  size 
)
void MEM_swap_short ( short *  i1,
short *  i2 
)

swap 2 shorts

void MEM_swap_int ( int *  i1,
int *  i2 
)

swap 2 ints

void MEM_swap_2lg ( long *  i1,
long *  i2 
)

swap 2 longs

void MEM_swap_2db ( double *  ,
double *   
)

swap 2 doubles

void MEM_swap_2vp ( void **  v1,
void **  v2 
)

swap 2 pointers (void*)

void* MEM_alloc_tmp ( int  )
MEM_alloc_tmp allocate mem for active function
DO NOT GET > 100000 byte
calls alloca; memspace exists until active function returns.
ptab = (Point*) MEM_alloc_tmp (nr_of_points * sizeof(Point));
ATTENTION: MinGW: use also alloca, not _alloca !!!
ATTENTION: MS needs more space!
int MEM_alloc_file ( void **  ,
long *  ,
char *   
)

UME_TMP_FILE allocate temp.memspace for file.