gCAD3D 2.35
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 
18 -----------------------------------------------------
19 */
25 typedef struct {void *start, *next, *end;
34  unsigned char typ, incSiz, u3, u4;} Memspc;
35 
36 
37 
38  int UME_init (Memspc *memSpc, void* objDat, int osiz);
39  int UME_alloc_tmp (Memspc *memSpc, long spcSiz);
40  int UME_malloc (Memspc *memSpc, long spcSiz, long memInc);
41  void* UME_save (Memspc *memSpc, void* objDat, int osiz);
42  void* UME_reserve (Memspc *memSpc, int osiz);
43  int UME_add (Memspc *memSpc, int osiz);
44  int UME_adjust (Memspc *memSpc, void* newStart);
45  int UME_ck_free (Memspc *memSpc);
46  int UME_set_free (int sizFree, Memspc *memSpc);
47  int UME_dump (Memspc *memSpc, char *txt);
48  int UME_del (Memspc *memSpc, void *nach, void *von, ...);
49  void UME_connect (void *memPos, Memspc *memSeg);
50 
51  int UME_reall_add (long *spcOff, Memspc *memSpc, long addSiz);
52  int UME_realloc (long *spcOff, Memspc *memSpc, long newSiz);
53  int UME_reall_save (long *spcOff, Memspc *memSpc, void* objDat, int osiz);
54 
55  void* UME_get_next (Memspc *memSpc);
56  void* UME_get_start (Memspc *memSpc);
57  long UME_get_used (Memspc *memSpc);
58 
59 
61 #define UME_NEW {NULL, NULL, NULL, 0}
62 
63 
73 int UME_alloc_tmp (Memspc*, long);
74 #define UME_alloc_tmp(memSeg,memsiz)\
75  UME_init (memSeg, MEM_alloc_tmp(memsiz), memsiz)
76 
77 
79 #define UME_get_next(memSeg) ((memSeg)->next)
80 
81 
84 #define UME_set_next(memPos,memSeg) (memSeg)->next=memPos
85 
86 
89 #define UME_get_start(memSeg) (memSeg)->start
90 
91 
93 #define UME_get_used(memSeg) ((char*)(memSeg)->next - (char*)(memSeg)->start)
94 
95 
100 #define UME_connect(memPos,memSeg)(memPos)=(memSeg)->next
101 
102 
103 // /// UME_TMP_FILE allocate temp.memspace for file
104 // int UME_TMP_FILE (void**, long*, char*);
105 // #define UME_TMP_FILE(fBuf, fSiz, fNam)\
106 // *fSiz = OS_FilSiz (fNam);\
107 // *fBuf = (void*)MEM_alloc_tmp (*fSiz)
108 
109 
110 
111 //----------------------------------------------------------------
118 #ifdef _LP64
119 typedef struct { int mbID; int ioff; } MemObj;
120 // #define MEMOBJ_NR_MAX 1000
121 #else
122 typedef struct { unsigned mbID:8, ioff:24;} MemObj;
123 // #define MEMOBJ_NR_MAX 128
124 #endif
125 
126 // get mem_obj as void* (have same size)
127 typedef union {void* vp; MemObj mo;} memobj_union;
128 // example:
129 // ((memobj_union)((Obj_Unknown*)gWin)->mem_obj).vp);
130 
131 
132 // pointer from MemObj
133 #define PTR_MEMOBJ(MO) ((memobj_union*)&MO)->vp
134 // MemObj from pointer
135 // #define MEMOBJ_PTR(p) ((memobj_union)p).mo
136 #define MEMOBJ_PTR(p) ((memobj_union*)p)->mo
137 
138 
141 #define UME_obj_IS_VALID(mo1) (int)((mo1)->ioff - 4)
142 
143 
144  MemObj UME_obj_reserve (void **oPos, Memspc *mSpc, int siz, int mbId);
145  int UME_obj_save (int mbId, Memspc *mSpc, int recNr);
146  void* UME_obj_get (MemObj *mo);
147  MemObj UME_obj_invalid_set (int iErr);
148 
149 
150 
151 //======================== EOF ======================================
int typ
Definition: xa_tra.c:151
int UME_ck_free(Memspc *memSpc)
Definition: ut_umem.c:713
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:257
Definition: ut_umem.h:127
Definition: ut_umem.h:122
int UME_add(Memspc *memSpc, int osiz)
Definition: ut_umem.c:518
int UME_obj_save(int mbId, Memspc *mSpc, int recNr)
Definition: ut_umem.c:890
void * vp
Definition: ut_umem.h:127
static char * memSpc
Definition: vr2_r.c:534
#define UME_connect(memPos, memSeg)
Definition: ut_umem.h:100
void * UME_obj_get(MemObj *mo)
Definition: ut_umem.c:908
#define UME_get_next(memSeg)
UME_get_next get actual memSpacePosition (.next; next free position)
Definition: ut_umem.h:79
#define UME_get_start(memSeg)
Definition: ut_umem.h:89
int UME_del(Memspc *memSpc, void *nach, void *von,...)
Definition: ut_umem.c:791
unsigned char u4
Definition: ut_umem.h:34
void * UME_reserve(Memspc *memSpc, int osiz)
Definition: ut_umem.c:484
MemObj UME_obj_invalid_set(int iErr)
Definition: ut_umem.c:935
void * UME_save(Memspc *memSpc, void *objDat, int osiz)
Definition: ut_umem.c:684
int UME_set_free(int sizFree, Memspc *memSpc)
Definition: ut_umem.c:744
int UME_init(Memspc *memSpc, void *objDat, int osiz)
Definition: ut_umem.c:423
#define UME_get_used(memSeg)
UME_get_used get used space.
Definition: ut_umem.h:93
int UME_malloc(Memspc *memSpc, long spcSiz, long memInc)
Definition: ut_umem.c:313
#define UME_alloc_tmp(memSeg, memsiz)
Definition: ut_umem.h:74
int UME_dump(Memspc *memSpc, char *txt)
Definition: ut_umem.c:776
int UME_adjust(Memspc *memSpc, void *newStart)
Definition: ut_umem.c:467
int UME_reall_add(long *spcOff, Memspc *memSpc, long addSiz)
Definition: ut_umem.c:567
Typ_Memspc (a class for variable-length-records in memory)
Definition: ut_umem.h:33
int UME_reall_save(long *spcOff, Memspc *memSpc, void *objDat, int osiz)
Definition: ut_umem.c:621