gCAD3D 2.40
ut_umem.h
Go to the documentation of this file.
1 /*
2  * fn.ft
3  *
4  * Copyright (C) 2012 CADCAM-Services Franz Reiter (franz.reiter@cadcam.co.at)
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16 -----------------------------------------------------
17 */
24 typedef struct {void *start, *next, *end;
33  unsigned char typ, incSiz, u3, u4;} Memspc;
34 
35 
36 
37  int UME_init (Memspc *memSpc, void* objDat, int osiz);
38  int UME_malloc (Memspc *memSpc, long spcSiz, long memInc);
39  void* UME_save (Memspc *memSpc, void* objDat, int osiz);
40  void* UME_reserve (Memspc *memSpc, int osiz);
41  int UME_add (Memspc *memSpc, int osiz);
42  int UME_adjust (Memspc *memSpc, void* newStart);
43  int UME_ck_tot (Memspc *memSpc);
44  int UME_ck_free (Memspc *memSpc);
45  int UME_set_free (int sizFree, Memspc *memSpc);
46  int UME_dump (Memspc *memSpc, char *txt);
47  int UME_del (Memspc *memSpc, void *nach, void *von, ...);
48  void UME_connect (void *memPos, Memspc *memSeg);
49 
50  int UME_reall_add (long *spcOff, Memspc *memSpc, long addSiz);
51  int UME_realloc (long *spcOff, Memspc *memSpc, long newSiz);
52  int UME_reall_save (long *spcOff, Memspc *memSpc, void* objDat, int osiz);
53 
54  void* UME_get_next (Memspc *memSpc);
55  void* UME_get_start (Memspc *memSpc);
56  long UME_get_used (Memspc *memSpc);
57 
58 
63 #define UME_NEW {NULL, NULL, NULL, 0}
64 
65 
70 #define UME_get_next(memSeg) ((memSeg)->next)
71 
72 
81 #define UME_set_next(memPos,memSeg) (memSeg)->next=memPos
82 
83 
86 #define UME_get_start(memSeg) (memSeg)->start
87 
88 
90 #define UME_get_used(memSeg) ((char*)(memSeg)->next - (char*)(memSeg)->start)
91 
92 
97 #define UME_connect(memPos,memSeg)(memPos)=(memSeg)->next
98 
99 
100 // /// UME_TMP_FILE allocate temp.memspace for file
101 // int UME_TMP_FILE (void**, long*, char*);
102 // #define UME_TMP_FILE(fBuf, fSiz, fNam)\
103 // *fSiz = OS_FilSiz (fNam);\
104 // *fBuf = (void*)MEM_alloc_tmp (*fSiz)
105 
106 
107 
108 //----------------------------------------------------------------
115 #ifdef _LP64
116 typedef struct { int mbID; int ioff; } MemObj;
117 // #define MEMOBJ_NR_MAX 1000
118 #else
119 typedef struct { unsigned mbID:8, ioff:24;} MemObj;
120 // #define MEMOBJ_NR_MAX 128
121 #endif
122 
123 // get mem_obj as void* (have same size)
124 typedef union {void* vp; MemObj mo;} memobj_union;
125 // example:
126 // ((memobj_union)((Obj_Unknown*)gWin)->mem_obj).vp);
127 
128 
129 // pointer from MemObj
130 #define PTR_MEMOBJ(MO) ((memobj_union*)&MO)->vp
131 // MemObj from pointer
132 // #define MEMOBJ_PTR(p) ((memobj_union)p).mo
133 #define MEMOBJ_PTR(p) ((memobj_union*)p)->mo
134 
135 
138 #define UME_obj_IS_VALID(mo1) (int)((mo1)->ioff - 4)
139 
140 
141  MemObj UME_obj_reserve (void **oPos, Memspc *mSpc, int siz, int mbId);
142  int UME_obj_save (int mbId, Memspc *mSpc, int recNr);
143  void* UME_obj_get (MemObj *mo);
144  MemObj UME_obj_invalid_set (int iErr);
145 
146 
147 
148 //======================== EOF ======================================
int typ
Definition: xa_tra.c:151
int UME_adjust(Memspc *memSpc, void *nxtFree)
Definition: ut_umem.c:466
Definition: ut_umem.h:124
Definition: ut_umem.h:119
int UME_obj_save(int mbId, Memspc *mSpc, int recNr)
Definition: ut_umem.c:890
int UME_reall_save(long *spcOff, Memspc *memSpc, void *objDat, int osiz)
Definition: ut_umem.c:620
void * vp
Definition: ut_umem.h:124
static char * memSpc
Definition: vr2_r.c:534
int UME_add(Memspc *memSpc, int osiz)
Definition: ut_umem.c:517
#define UME_connect(memPos, memSeg)
Definition: ut_umem.h:97
void * UME_obj_get(MemObj *mo)
Definition: ut_umem.c:908
int UME_del(Memspc *memSpc, void *nach, void *von,...)
Definition: ut_umem.c:791
#define UME_get_next(memSeg)
Definition: ut_umem.h:70
#define UME_get_start(memSeg)
Definition: ut_umem.h:86
unsigned char u4
Definition: ut_umem.h:33
int UME_set_free(int sizFree, Memspc *memSpc)
Definition: ut_umem.c:744
void * UME_reserve(Memspc *memSpc, int osiz)
Definition: ut_umem.c:483
int UME_init(Memspc *memSpc, void *objDat, int osiz)
Definition: ut_umem.c:422
void * UME_save(Memspc *memSpc, void *objDat, int osiz)
Definition: ut_umem.c:683
int UME_dump(Memspc *memSpc, char *txt)
Definition: ut_umem.c:776
MemObj UME_obj_invalid_set(int iErr)
Definition: ut_umem.c:935
#define UME_get_used(memSeg)
UME_get_used get used space.
Definition: ut_umem.h:90
int UME_ck_tot(Memspc *memSpc)
Definition: ut_umem.c:734
int UME_malloc(Memspc *memSpc, long spcSiz, long memInc)
Definition: ut_umem.c:312
int UME_reall_add(long *spcOff, Memspc *memSpc, long addSiz)
Definition: ut_umem.c:566
MemObj UME_obj_reserve(void **oPos, Memspc *mSpc, int siz, int mbId)
Definition: ut_umem.c:868
int UME_realloc(long *spcOff, Memspc *memSpc, long newSiz)
Definition: ut_umem.c:256
Typ_Memspc (a class for variable-length-records in memory)
Definition: ut_umem.h:32
int UME_ck_free(Memspc *memSpc)
Definition: ut_umem.c:712