GnuCOBOL  2.0
A free COBOL compiler
vbmemio.c File Reference
#include "isinternal.h"
Include dependency graph for vbmemio.c:

Go to the source code of this file.

Macros

#define vb_error(x)
 

Functions

void * pvvbmalloc (const size_t size)
 
void vvbfree (void *mptr)
 
struct VBLOCKpsvblockallocate (const int ihandle)
 
void vvblockfree (struct VBLOCK *pslock)
 
struct VBTREEpsvbtreeallocate (const int ihandle)
 
void vvbtreeallfree (const int ihandle, const int ikeynumber, struct VBTREE *pstree)
 
struct VBKEYpsvbkeyallocate (const int ihandle, const int ikeynumber)
 
void vvbkeyallfree (const int ihandle, const int ikeynumber, struct VBTREE *pstree)
 
void vvbkeyfree (const int ihandle, const int ikeynumber, struct VBKEY *pskey)
 
void vvbkeyunmalloc (const int ihandle, const int ikeynumber)
 

Variables

static struct VBLOCKpslockfree = ((void*)0)
 
static struct VBTREEpstreefree = ((void*)0)
 
int iserrno = 0
 
int iserrio = 0
 
int isreclen = 0
 
int isrecnum = 0
 

Macro Definition Documentation

#define vb_error (   x)

Function Documentation

struct VBKEY* psvbkeyallocate ( const int  ihandle,
const int  ikeynumber 
)

Definition at line 120 of file vbmemio.c.

References NULL, DICTINFO::pskeydesc, DICTINFO::pskeyfree, VBKEY::psnext, psvbfile, pvvbmalloc(), VBKEY::trownode, and vb_error.

Referenced by inodesplit(), ivbkeyinsert(), and ivbnodeload().

121 {
122  struct VBKEY *pskey;
123  struct DICTINFO *psvbptr;
124  int ilength = 0;
125 
126  psvbptr = psvbfile[ihandle];
127  pskey = psvbptr->pskeyfree[ikeynumber];
128  if (pskey == NULL) {
129  ilength = psvbptr->pskeydesc[ikeynumber]->k_len;
130  pskey = pvvbmalloc (sizeof (struct VBKEY) + ilength);
131  } else {
132  if (pskey->trownode != -1) {
133  vb_error ("Keyallocated not free");
134  }
135  psvbptr->pskeyfree[ikeynumber] =
136  psvbptr->pskeyfree[ikeynumber]->psnext;
137  memset (pskey, 0, (sizeof (struct VBKEY) + ilength));
138  }
139  return pskey;
140 }
#define vb_error(x)
Definition: vbmemio.c:41
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
off_t trownode
Definition: isinternal.h:328
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

struct VBLOCK* psvblockallocate ( const int  ihandle)

Definition at line 67 of file vbmemio.c.

References NULL, pslockfree, VBLOCK::psnext, and pvvbmalloc().

Referenced by ilockinsert().

68 {
69  struct VBLOCK *pslock = pslockfree;
70 
71  if (pslockfree != NULL) {
73  memset (pslock, 0, sizeof (struct VBLOCK));
74  } else {
75  pslock = pvvbmalloc (sizeof (struct VBLOCK));
76  }
77  return pslock;
78 }
struct VBLOCK * psnext
Definition: isinternal.h:318
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static struct VBLOCK * pslockfree
Definition: vbmemio.c:22

Here is the call graph for this function:

Here is the caller graph for this function:

struct VBTREE* psvbtreeallocate ( const int  ihandle)

Definition at line 88 of file vbmemio.c.

References NULL, VBTREE::psnext, pstreefree, pvvbmalloc(), VBTREE::tnodenumber, and vb_error.

Referenced by inodesplit(), itreeload(), and ivbkeyload().

89 {
90  struct VBTREE *pstree = pstreefree;
91 
92  if (pstreefree == NULL) {
93  pstree = pvvbmalloc (sizeof (struct VBTREE));
94  } else {
96  if (pstree->tnodenumber != -1) {
97  vb_error ("Treeallocated not free");
98  }
99  memset (pstree, 0, sizeof (struct VBTREE));
100  }
101  return pstree;
102 }
static struct VBTREE * pstreefree
Definition: vbmemio.c:23
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * psnext
Definition: isinternal.h:338
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
off_t tnodenumber
Definition: isinternal.h:343

Here is the call graph for this function:

Here is the caller graph for this function:

void* pvvbmalloc ( const size_t  size)

Definition at line 45 of file vbmemio.c.

References unlikely.

Referenced by ipreamble(), iprocessdelete(), ircvbegin(), ircvchecktrans(), ircvfileopen(), isaddindex(), isbuild(), isdi_kdsc(), isopen(), isrecover(), psvbkeyallocate(), psvblockallocate(), and psvbtreeallocate().

46 {
47  void *mptr;
48 
49  mptr = calloc (1, size);
50  if (unlikely(!mptr)) {
51  fprintf (stderr, "Cannot allocate %d bytes of memory - Aborting\n", size);
52  fflush (stderr);
53  exit (1);
54  }
55  return mptr;
56 }
#define unlikely(x)
Definition: common.h:437

Here is the caller graph for this function:

void vvbfree ( void *  mptr)

Definition at line 59 of file vbmemio.c.

Referenced by ipostamble(), ircvcommit(), ircvfileopen(), ircvrollback(), isbuild(), isdelindex(), isopen(), isrecover(), ivbclose3(), and vvbkeyunmalloc().

60 {
61  if (mptr) {
62  free (mptr);
63  }
64 }

Here is the caller graph for this function:

void vvbkeyallfree ( const int  ihandle,
const int  ikeynumber,
struct VBTREE pstree 
)

Definition at line 143 of file vbmemio.c.

References VBTREE::ikeysinnode, NULL, VBKEY::pschild, VBTREE::pskeycurr, VBTREE::pskeyfirst, DICTINFO::pskeyfree, VBTREE::pskeylast, VBKEY::psnext, psvbfile, VBKEY::trownode, vb_error, and vvbtreeallfree().

Referenced by ichecktree(), and vvbtreeallfree().

144 {
145  struct DICTINFO *psvbptr;
146  struct VBKEY *pskeycurr;
147  struct VBKEY *pskeynext;
148 
149  psvbptr = psvbfile[ihandle];
150  pskeycurr = pstree->pskeyfirst;
151  while (pskeycurr) {
152  if (pskeycurr->trownode == -1) {
153  vb_error ("Keyfreed already free");
154  }
155  pskeynext = pskeycurr->psnext;
156  if (pskeycurr->pschild) {
157  vvbtreeallfree (ihandle, ikeynumber, pskeycurr->pschild);
158  }
159  pskeycurr->pschild = NULL;
160  pskeycurr->psnext = psvbptr->pskeyfree[ikeynumber];
161  psvbptr->pskeyfree[ikeynumber] = pskeycurr;
162  pskeycurr->trownode = -1;
163  pskeycurr = pskeynext;
164  }
165  pstree->pskeyfirst = NULL;
166  pstree->pskeylast = NULL;
167  pstree->pskeycurr = NULL;
168  pstree->ikeysinnode = 0;
169 }
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * pschild
Definition: isinternal.h:327
struct VBKEY * pskeylast
Definition: isinternal.h:341
struct VBKEY * pskeycurr
Definition: isinternal.h:342
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
off_t trownode
Definition: isinternal.h:328
unsigned int ikeysinnode
Definition: isinternal.h:346
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

void vvbkeyfree ( const int  ihandle,
const int  ikeynumber,
struct VBKEY pskey 
)

Definition at line 172 of file vbmemio.c.

References NULL, VBKEY::pschild, DICTINFO::pskeyfree, VBKEY::psnext, VBKEY::psprev, psvbfile, VBKEY::trownode, vb_error, and vvbtreeallfree().

Referenced by ivbkeydelete(), and ivbnodeload().

173 {
174  struct DICTINFO *psvbptr;
175 
176  if (pskey->trownode == -1) {
177  vb_error ("Keyfreed already free");
178  }
179  psvbptr = psvbfile[ihandle];
180  if (pskey->pschild) {
181  vvbtreeallfree (ihandle, ikeynumber, pskey->pschild);
182  }
183  pskey->pschild = NULL;
184  if (pskey->psnext) {
185  pskey->psnext->psprev = pskey->psprev;
186  }
187  if (pskey->psprev) {
188  pskey->psprev->psnext = pskey->psnext;
189  }
190  pskey->psnext = psvbptr->pskeyfree[ikeynumber];
191  psvbptr->pskeyfree[ikeynumber] = pskey;
192  pskey->trownode = -1;
193 }
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * pschild
Definition: isinternal.h:327
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
off_t trownode
Definition: isinternal.h:328
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

void vvbkeyunmalloc ( const int  ihandle,
const int  ikeynumber 
)

Definition at line 196 of file vbmemio.c.

References DICTINFO::pskeyfree, VBKEY::psnext, psvbfile, and vvbfree().

Referenced by isdelindex(), and ivbclose3().

197 {
198  struct DICTINFO *psvbptr;
199  struct VBKEY *pskeycurr;
200 /* RXW
201  int ilength;
202 */
203 
204  psvbptr = psvbfile[ihandle];
205  pskeycurr = psvbptr->pskeyfree[ikeynumber];
206 /* RXW
207  ilength = sizeof (struct VBKEY) + psvbptr->pskeydesc[ikeynumber]->k_len;
208 */
209  while (pskeycurr) {
210  psvbptr->pskeyfree[ikeynumber] =
211  psvbptr->pskeyfree[ikeynumber]->psnext;
212  vvbfree (pskeycurr);
213  pskeycurr = psvbptr->pskeyfree[ikeynumber];
214  }
215 }
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbfree(void *mptr)
Definition: vbmemio.c:59
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

void vvblockfree ( struct VBLOCK pslock)

Definition at line 81 of file vbmemio.c.

References pslockfree, and VBLOCK::psnext.

Referenced by ilockdelete(), and ivbclose2().

82 {
83  pslock->psnext = pslockfree;
84  pslockfree = pslock;
85 }
struct VBLOCK * psnext
Definition: isinternal.h:318
static struct VBLOCK * pslockfree
Definition: vbmemio.c:22

Here is the caller graph for this function:

void vvbtreeallfree ( const int  ihandle,
const int  ikeynumber,
struct VBTREE pstree 
)

Definition at line 105 of file vbmemio.c.

References VBTREE::psnext, pstreefree, VBTREE::tnodenumber, vb_error, and vvbkeyallfree().

Referenced by iindexcheck(), isdelindex(), itreeload(), ivbclose3(), ivbenter(), ivbexit(), ivbkeydelete(), ivbkeyload(), ivbnodeload(), vvbkeyallfree(), and vvbkeyfree().

106 {
107  if (!pstree) {
108  return;
109  }
110  if (pstree->tnodenumber == -1) {
111  vb_error ("Treefreed not free");
112  }
113  vvbkeyallfree (ihandle, ikeynumber, pstree);
114  pstree->psnext = pstreefree;
115  pstreefree = pstree;
116  pstree->tnodenumber = -1;
117 }
static struct VBTREE * pstreefree
Definition: vbmemio.c:23
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * psnext
Definition: isinternal.h:338
off_t tnodenumber
Definition: isinternal.h:343
void vvbkeyallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:143

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int iserrio = 0

Definition at line 28 of file vbmemio.c.

int iserrno = 0

Definition at line 27 of file vbmemio.c.

Referenced by iaddkeydescriptor(), idemotelocks(), imakekeysfromdata(), indexed_open(), indexed_read(), indexed_read_next(), inodesplit(), iprocessdelete(), ircvbuild(), ircvcreateindex(), ircvdelete(), ircvdeleteindex(), ircvfileclose(), ircvfileerase(), ircvfileopen(), ircvfilerename(), ircvinsert(), ircvsetunique(), ircvupdate(), irowdelete(), irowinsert(), irowupdate(), isaddindex(), isaudit(), isbegin(), isbuild(), ischeck(), iscleanup(), isclose(), iscluster(), iscommit(), isdelcurr(), isdelete(), isdelindex(), isdelrec(), isdi_curidx(), isdi_datfd(), isdi_datlen(), isdi_idxfd(), isdi_kdsc(), isdi_name(), isflush(), isfullclose(), isindexinfo(), islock(), islogclose(), islogopen(), isopen(), isread(), isrecover(), isrelcurr(), isrelease(), isrelrec(), isrename(), isrewcurr(), isrewrec(), isrewrite(), isrollback(), issetcollate(), issetunique(), isstart(), istartrownumber(), isuniqueid(), isunlock(), iswrcurr(), iswrite(), itreeload(), ivbcheckkey(), ivbclose2(), ivbdatafree(), ivbdataread(), ivbdatawrite(), ivbenter(), ivbexit(), ivbforcedataallocate(), ivbforceexit(), ivbkeylocaterow(), ivbkeysearch(), ivbnodefree(), ivbrollmeback(), ivbtransbuild(), ivbtransclose(), ivbtranscreateindex(), ivbtransdelete(), ivbtransdeleteindex(), ivbtranserase(), ivbtransinsert(), ivbtransopen(), ivbtransrename(), ivbtranssetunique(), ivbtransuniqueid(), ivbtransupdate(), ivbvarlenread(), ivbwriterow(), tdelkeydescriptor(), tvbdataallocate(), tvbdatacountgetnext(), tvbnodeallocate(), tvbnodecountgetnext(), vaddkeyforrow(), vrebuilddatafree(), and vrebuildindexfree().

struct VBLOCK* pslockfree = ((void*)0)
static

Definition at line 22 of file vbmemio.c.

Referenced by psvblockallocate(), and vvblockfree().

struct VBTREE* pstreefree = ((void*)0)
static

Definition at line 23 of file vbmemio.c.

Referenced by psvbtreeallocate(), and vvbtreeallfree().