#define __INLINE__ __inline
#endif
-/* Void_t is defined so that Void_t* can address any type */
-#ifndef Void_t
-#define Void_t void
-#endif /*Void_t */
-
/* dynamic linked library external scope handling */
#undef extern
#if defined(_dll_import) && !defined(__EXPORT__) && _DLL_BLD
/* freef:
* Generic free function for dictionaries.
*/
-static void freef(Dt_t * dt, Void_t * obj, Dtdisc_t * disc)
+static void freef(Dt_t * dt, void * obj, Dtdisc_t * disc)
{
free(obj);
}
#define __INLINE__ __inline
#endif
- /* Void_t is defined so that Void_t* can address any type */
- #ifndef Void_t
- #define Void_t void
- #endif /*Void_t*/
-
/* dynamic linked library external scope handling */
#undef extern
#if _dll_import && !defined(__EXPORT__) && _DLL_BLD
.Ce
.Ss "DICTIONARY TYPES"
.Cs
-Void_t*;
Dt_t;
Dtdisc_t;
Dtmethod_t;
.Cs
#define DTOFFSET(struct_s,member)
#define DTDISC(disc,key,size,link,makef,freef,comparf,hashf,memoryf,eventf)
-typedef Void_t* (*Dtmake_f)(Dt_t*, Void_t*, Dtdisc_t*);
-typedef void (*Dtfree_f)(Dt_t*, Void_t*, Dtdisc_t*);
-typedef int (*Dtcompar_f)(Dt_t*, Void_t*, Void_t*, Dtdisc_t*);
-typedef unsigned int (*Dthash_f)(Dt_t*, Void_t*, Dtdisc_t*);
-typedef Void_t* (*Dtmemory_f)(Dt_t*, Void_t*, size_t, Dtdisc_t*);
-typedef int (*Dtevent_f)(Dt_t*, int, Void_t*, Dtdisc_t*);
+typedef void* (*Dtmake_f)(Dt_t*, void*, Dtdisc_t*);
+typedef void (*Dtfree_f)(Dt_t*, void*, Dtdisc_t*);
+typedef int (*Dtcompar_f)(Dt_t*, void*, void*, Dtdisc_t*);
+typedef unsigned int (*Dthash_f)(Dt_t*, void*, Dtdisc_t*);
+typedef void* (*Dtmemory_f)(Dt_t*, void*, size_t, Dtdisc_t*);
+typedef int (*Dtevent_f)(Dt_t*, int, void*, Dtdisc_t*);
.Ce
.Ss "OBJECT OPERATIONS"
.Cs
-Void_t* dtinsert(Dt_t* dt, Void_t* obj);
-Void_t* dtappend(Dt_t* dt, Void_t* obj);
-Void_t* dtdelete(Dt_t* dt, Void_t* obj);
-Void_t* dtattach(Dt_t* dt, Void_t* obj);
-Void_t* dtdetach(Dt_t* dt, Void_t* obj);
-Void_t* dtsearch(Dt_t* dt, Void_t* obj);
-Void_t* dtmatch(Dt_t* dt, Void_t* key);
-Void_t* dtfirst(Dt_t* dt);
-Void_t* dtnext(Dt_t* dt, Void_t* obj);
-Void_t* dtlast(Dt_t* dt);
-Void_t* dtprev(Dt_t* dt, Void_t* obj);
-Void_t* dtfinger(Dt_t* dt);
-Void_t* dtrenew(Dt_t* dt, Void_t* obj);
-int dtwalk(Dt_t* dt, int (*userf)(Dt_t*, Void_t*, Void_t*), Void_t*);
+void* dtinsert(Dt_t* dt, void* obj);
+void* dtappend(Dt_t* dt, void* obj);
+void* dtdelete(Dt_t* dt, void* obj);
+void* dtattach(Dt_t* dt, void* obj);
+void* dtdetach(Dt_t* dt, void* obj);
+void* dtsearch(Dt_t* dt, void* obj);
+void* dtmatch(Dt_t* dt, void* key);
+void* dtfirst(Dt_t* dt);
+void* dtnext(Dt_t* dt, void* obj);
+void* dtlast(Dt_t* dt);
+void* dtprev(Dt_t* dt, void* obj);
+void* dtfinger(Dt_t* dt);
+void* dtrenew(Dt_t* dt, void* obj);
+int dtwalk(Dt_t* dt, int (*userf)(Dt_t*, void*, void*), void*);
Dtlink_t* dtflatten(Dt_t* dt);
Dtlink_t* dtlink(Dt_t*, Dtlink_t* link);
-Void_t* dtobj(Dt_t* dt, Dtlink_t* link);
+void* dtobj(Dt_t* dt, Dtlink_t* link);
Dtlink_t* dtextract(Dt_t* dt);
int dtrestore(Dt_t* dt, Dtlink_t* link);
-#define DTTREESEARCH(Dt_t* dt, Void_t* obj, action)
-#define DTTREEMATCH(Dt_t* dt, Void_t* key, action)
+#define DTTREESEARCH(Dt_t* dt, void* obj, action)
+#define DTTREEMATCH(Dt_t* dt, void* key, action)
.Ce
.Ss "DICTIONARY STATUS"
.Cs
.PP
.Ss "DICTIONARY TYPES"
.PP
-.Ss " Void_t*"
-This type is used to pass objects between \fICdt\fP and application code.
-\f5Void_t\fP is defined as \f5void\fP for ANSI-C and C++
-and \f5char\fP for other compilation environments.
-.PP
.Ss " Dt_t"
This is the type of a dictionary handle.
.PP
Each object \f5obj\fP is identified by a key used for object comparison or hashing.
\f5key\fP should be non-negative and defines an offset into \f5obj\fP.
If \f5size\fP is negative, the key is a null-terminated
-string with starting address \f5*(Void_t**)((char*)obj+key)\fP.
+string with starting address \f5*(void**)((char*)obj+key)\fP.
If \f5size\fP is zero, the key is a null-terminated string with starting address
-\f5(Void_t*)((char*)obj+key)\fP.
+\f5(void*)((char*)obj+key)\fP.
Finally, if \f5size\fP is positive, the key is a byte array of length \f5size\fP
-starting at \f5(Void_t*)((char*)obj+key)\fP.
+starting at \f5(void*)((char*)obj+key)\fP.
.PP
.Ss " int link"
Let \f5obj\fP be an object to be inserted into \f5dt\fP as discussed below.
a \f5Dtlink_t\fP structure embedded \f5link\fP bytes into it,
i.e., at address \f5(Dtlink_t*)((char*)obj+link)\fP.
.PP
-.Ss " Void_t* (*makef)(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)"
+.Ss " void* (*makef)(Dt_t* dt, void* obj, Dtdisc_t* disc)"
If \f5makef\fP is not \f5NULL\fP,
\f5dtinsert(dt,obj)\fP or \f5dtappend()\fP will call it
to make a copy of \f5obj\fP suitable for insertion into \f5dt\fP.
If \f5makef\fP is \f5NULL\fP, \f5obj\fP itself will be inserted into \f5dt\fP.
.PP
-.Ss " void (*freef)(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)"
+.Ss " void (*freef)(Dt_t* dt, void* obj, Dtdisc_t* disc)"
If not \f5NULL\fP,
\f5freef\fP is used to destroy data associated with \f5obj\fP.
.PP
-.Ss "int (*comparf)(Dt_t* dt, Void_t* key1, Void_t* key2, Dtdisc_t* disc)"
+.Ss "int (*comparf)(Dt_t* dt, void* key1, void* key2, Dtdisc_t* disc)"
If not \f5NULL\fP, \f5comparf\fP is used to compare two keys.
Its return value should be \f5<0\fP, \f5=0\fP, or \f5>0\fP to indicate
whether \f5key1\fP is smaller, equal to, or larger than \f5key2\fP.
If \f5(*comparf)()\fP is \f5NULL\fP, an internal function is used
to compare the keys as defined by the \f5Dtdisc_t.size\fP field.
.PP
-.Ss " unsigned int (*hashf)(Dt_t* dt, Void_t* key, Dtdisc_t* disc)"
+.Ss " unsigned int (*hashf)(Dt_t* dt, void* key, Dtdisc_t* disc)"
If not \f5NULL\fP,
\f5hashf\fP is used to compute the hash value of \f5key\fP.
It is required that keys compared equal will also have same hash values.
If \f5hashf\fP is \f5NULL\fP, an internal function is used to hash
the key as defined by the \f5Dtdisc_t.size\fP field.
.PP
-.Ss " Void_t* (*memoryf)(Dt_t* dt, Void_t* addr, size_t size, Dtdisc_t* disc)"
+.Ss " void* (*memoryf)(Dt_t* dt, void* addr, size_t size, Dtdisc_t* disc)"
If not \f5NULL\fP, \f5memoryf\fP is used to allocate and free memory.
When \f5addr\fP is \f5NULL\fP, a memory segment of size \f5size\fP is requested.
If \f5addr\fP is not \f5NULL\fP and \f5size\fP is zero, \f5addr\fP is to be freed.
\f5addr\fP is to be resized to the given size.
If \f5memoryf\fP is \f5NULL\fP, \fImalloc(3)\fP is used.
.PP
-.Ss " int (*eventf)(Dt_t* dt, int type, Void_t* data, Dtdisc_t* disc)"
+.Ss " int (*eventf)(Dt_t* dt, int type, void* data, Dtdisc_t* disc)"
If not \f5NULL\fP, \f5eventf\fP announces various events.
Each event may have particular handling of the return values from \f5eventf\fP.
But a negative return value typically means failure.
If \f5eventf\fP returns negative, the opening process terminates with failure.
If \f5eventf\fP returns zero, the opening process proceeds in a default manner.
A positive return value indicates special treatment of memory as follows.
-If \f5*(Void_t**)data\fP is set to point to some memory segment
+If \f5*(void**)data\fP is set to point to some memory segment
as discussed in \f5memoryf\fP, that segment of memory is used to start
-the dictionary. If \f5*(Void_t**)data\fP is \f5NULL\fP,
+the dictionary. If \f5*(void**)data\fP is \f5NULL\fP,
all memory including that of the dictionary handle itself
will be allocated via \f5memoryf\fP.
.Tp
.PP
.Ss "OBJECT OPERATIONS"
.PP
-.Ss " Void_t* dtinsert(Dt_t* dt, Void_t* obj)"
-.Ss " Void_t* dtappend(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtinsert(Dt_t* dt, void* obj)"
+.Ss " void* dtappend(Dt_t* dt, void* obj)"
These functions add an object prototyped by \f5obj\fP into \f5dt\fP.
\f5dtinsert()\fP and \f5dtappend()\fP perform the same function
for all methods except for \f5Dtlist\fP. See \f5Dtlist\fP for details.
The new object or a matching object as noted will be returned on success
while \f5NULL\fP is returned on error.
.PP
-.Ss " Void_t* dtdelete(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtdelete(Dt_t* dt, void* obj)"
If \f5obj\fP is \f5NULL\fP, methods \f5Dtstack\fP and \f5Dtqueue\fP
delete respectively stack top or queue head while other methods do nothing.
If \f5obj\fP is not \f5NULL\fP, there are two cases.
\f5dtdelete()\fP returns the deleted object (even if it was deallocated)
or \f5NULL\fP on error.
.PP
-.Ss " Void_t* dtattach(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtattach(Dt_t* dt, void* obj)"
This function is similar to \f5dtinsert()\fP but \f5obj\fP itself
will be inserted into \f5dt\fP even if a discipline
function \f5makef\fP is defined.
.PP
-.Ss " Void_t* dtdetach(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtdetach(Dt_t* dt, void* obj)"
This function is similar to \f5dtdelete()\fP but the object to be deleted
from \f5dt\fP will not be freed (via the discipline \f5freef\fP function).
.PP
-.Ss " Void_t* dtsearch(Dt_t* dt, Void_t* obj)"
-.Ss " Void_t* dtmatch(Dt_t* dt, Void_t* key)"
+.Ss " void* dtsearch(Dt_t* dt, void* obj)"
+.Ss " void* dtmatch(Dt_t* dt, void* key)"
These functions find an object matching \f5obj\fP or \f5key\fP either from \f5dt\fP or
from some dictionary accessible from \f5dt\fP via a viewpath (see \f5dtview()\fP.)
\f5dtsearch()\fP and \f5dtmatch()\fP return the matching object or
\f5NULL\fP on failure.
.PP
-.Ss " Void_t* dtfirst(Dt_t* dt)"
-.Ss " Void_t* dtnext(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtfirst(Dt_t* dt)"
+.Ss " void* dtnext(Dt_t* dt, void* obj)"
\f5dtfirst()\fP returns the first object in \f5dt\fP.
\f5dtnext()\fP returns the object following \f5obj\fP.
Objects are ordered based on the storage method in use.
Nested loops will require multiple balancing, once per loop.
If loop balancing is not done carefully, either performance is degraded
or unexpected behaviors may result.
-.Ss " Void_t* dtlast(Dt_t* dt)"
-.Ss " Void_t* dtprev(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtlast(Dt_t* dt)"
+.Ss " void* dtprev(Dt_t* dt, void* obj)"
\f5dtlast()\fP and \f5dtprev()\fP are like \f5dtfirst()\fP and \f5dtnext()\fP
but work in reverse order.
Note that dictionaries on a viewpath are still walked in order
but objects in each dictionary are walked in reverse order.
.PP
-.Ss " Void_t* dtfinger(Dt_t* dt)"
+.Ss " void* dtfinger(Dt_t* dt)"
This function returns the \fIcurrent object\fP of \f5dt\fP, if any.
The current object is defined after a successful call to one of
\f5dtsearch()\fP, \f5dtmatch()\fP, \f5dtinsert()\fP,
when a dictionary is based on \f5Dtoset\fP and \f5Dtobag\fP,
the current object is always defined and is the root of the tree.
.PP
-.Ss " Void_t* dtrenew(Dt_t* dt, Void_t* obj)"
+.Ss " void* dtrenew(Dt_t* dt, void* obj)"
This function repositions and perhaps rehashes
an object \f5obj\fP after its key has been changed.
\f5dtrenew()\fP only works if \f5obj\fP is the current object (see \f5dtfinger()\fP).
.PP
-.Ss " dtwalk(Dt_t* dt, int (*userf)(Dt_t*, Void_t*, Void_t*), Void_t* data)"
+.Ss " dtwalk(Dt_t* dt, int (*userf)(Dt_t*, void*, void*), void* data)"
This function calls \f5(*userf)(walk,obj,data)\fP on each object in \f5dt\fP and
other dictionaries viewable from it.
\f5walk\fP is the dictionary containing \f5obj\fP.
.PP
.Ss " Dtlink_t* dtflatten(Dt_t* dt)"
.Ss " Dtlink_t* dtlink(Dt_t* dt, Dtlink_t* link)"
-.Ss " Void_t* dtobj(Dt_t* dt, Dtlink_t* link)"
+.Ss " void* dtobj(Dt_t* dt, Dtlink_t* link)"
Using \f5dtfirst()/dtnext()\fP or \f5dtlast()/dtprev()\fP
to walk a single dictionary can incur significant cost due to function calls.
For efficient walking of a single directory (i.e., no viewpathing),
.Ce
.PP
Note that \f5dtflatten()\fP returns a list of type \f5Dtlink_t*\fP,
-not \f5Void_t*\fP. That is, it returns a dictionary holder pointer,
+not \f5void*\fP. That is, it returns a dictionary holder pointer,
not a user object pointer
(although both are the same if the discipline field \f5link\fP is zero.)
The macro function \f5dtlink()\fP
It is important that the same discipline and method are in use at both
extraction and restoration. Otherwise, undefined behaviors may result.
.PP
-.Ss " #define DTTREESEARCH(Dt_t* dt, Void_t* obj, action)"
-.Ss " #define DTTREEMATCH(Dt_t* dt, Void_t* key, action)"
+.Ss " #define DTTREESEARCH(Dt_t* dt, void* obj, action)"
+.Ss " #define DTTREEMATCH(Dt_t* dt, void* key, action)"
These macro functions are analogues of \f5dtsearch()\fP and \f5dtmatch()\fP
but they can only be used on a dictionary based on a binary
search tree, i.e., \f5Dtoset\fP or \f5Dtobag\fP.
#define CDT_VERSION 20050420L
-#ifndef Void_t
-#define Void_t void
-#endif
-
#include <stddef.h> /* size_t */
#include <string.h>
typedef struct _dt_s Dt_t;
typedef struct _dt_s Dict_t; /* for libdict compatibility */
typedef struct _dtstat_s Dtstat_t;
-typedef Void_t* (*Dtmemory_f)(Dt_t*,Void_t*,size_t,Dtdisc_t*);
-typedef Void_t* (*Dtsearch_f)(Dt_t*,Void_t*,int);
-typedef Void_t* (*Dtmake_f)(Dt_t*,Void_t*,Dtdisc_t*);
-typedef void (*Dtfree_f)(Dt_t*,Void_t*,Dtdisc_t*);
-typedef int (*Dtcompar_f)(Dt_t*,Void_t*,Void_t*,Dtdisc_t*);
-typedef unsigned int (*Dthash_f)(Dt_t*,Void_t*,Dtdisc_t*);
-typedef int (*Dtevent_f)(Dt_t*,int,Void_t*,Dtdisc_t*);
+typedef void* (*Dtmemory_f)(Dt_t*,void*,size_t,Dtdisc_t*);
+typedef void* (*Dtsearch_f)(Dt_t*,void*,int);
+typedef void* (*Dtmake_f)(Dt_t*,void*,Dtdisc_t*);
+typedef void (*Dtfree_f)(Dt_t*,void*,Dtdisc_t*);
+typedef int (*Dtcompar_f)(Dt_t*,void*,void*,Dtdisc_t*);
+typedef unsigned int (*Dthash_f)(Dt_t*,void*,Dtdisc_t*);
+typedef int (*Dtevent_f)(Dt_t*,int,void*,Dtdisc_t*);
struct _dtlink_s
{ Dtlink_t* right; /* right child */
/* private structure to hold an object */
struct _dthold_s
{ Dtlink_t hdr; /* header */
- Void_t* obj; /* user object */
+ void* obj; /* user object */
};
/* method to manipulate dictionary structure */
int nview; /* number of parent view dictionaries */
Dt_t* view; /* next on viewpath */
Dt_t* walk; /* dictionary being walked */
- Void_t* user; /* for user's usage */
+ void* user; /* for user's usage */
};
/* structure to get status of a dictionary */
extern int dttreeset(Dt_t*, int, int);
-extern int dtwalk(Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*);
+extern int dtwalk(Dt_t*, int(*)(Dt_t*,void*,void*), void*);
-extern Void_t* dtrenew(Dt_t*, Void_t*);
+extern void* dtrenew(Dt_t*, void*);
extern int dtsize(Dt_t*);
extern int dtstat(Dt_t*, Dtstat_t*, int);
-extern unsigned int dtstrhash(unsigned int, Void_t*, int);
+extern unsigned int dtstrhash(unsigned int, void*, int);
#undef extern
_END_EXTERNS_
#define _DTDSC(dc,ky,sz,lk,cmpf) \
(ky = dc->key, sz = dc->size, lk = dc->link, cmpf = dc->comparf)
#define _DTLNK(o,lk) ((Dtlink_t*)((char*)(o) + lk) )
-#define _DTOBJ(e,lk) (lk < 0 ? ((Dthold_t*)(e))->obj : (Void_t*)((char*)(e) - lk) )
-#define _DTKEY(o,ky,sz) (Void_t*)(sz < 0 ? *((char**)((char*)(o)+ky)) : ((char*)(o)+ky))
+#define _DTOBJ(e,lk) (lk < 0 ? ((Dthold_t*)(e))->obj : (void*)((char*)(e) - lk) )
+#define _DTKEY(o,ky,sz) (void*)(sz < 0 ? *((char**)((char*)(o)+ky)) : ((char*)(o)+ky))
#define _DTCMP(dt,k1,k2,dc,cmpf,sz) \
(cmpf ? (*cmpf)(dt,k1,k2,dc) : \
/* special search function for tree structure only */
#define _DTMTCH(dt,key,action) \
- do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ do { Dtlink_t* _e; void *_o, *_k, *_key; Dtdisc_t* _dc; \
int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
_dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
_key = (key); \
if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
break; \
} \
- action (_e ? _o : (Void_t*)0); \
+ action (_e ? _o : (void*)0); \
} while(0)
#define _DTSRCH(dt,obj,action) \
- do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ do { Dtlink_t* _e; void *_o, *_k, *_key; Dtdisc_t* _dc; \
int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
_dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
_key = _DTKEY(obj, _ky, _sz); \
if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
break; \
} \
- action (_e ? _o : (Void_t*)0); \
+ action (_e ? _o : (void*)0); \
} while(0)
-#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(Void_t*)(key),action)
-#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(Void_t*)(obj),action)
+#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(void*)(key),action)
+#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(void*)(obj),action)
#define dtvnext(d) (_DT(d)->view)
#define dtvcount(d) (_DT(d)->nview)
#define dtlink(d,e) (((Dtlink_t*)(e))->right)
#define dtobj(d,e) _DTOBJ((e), _DT(d)->disc->link)
-#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(Void_t*)(0))
-
-#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
-#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
-#define dtleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_NEXT)
-#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST)
-#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV)
-#define dtmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_PREV)
-#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
-#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
-#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
-#define dtappend(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT|DT_APPEND)
-#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
-#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
-#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
-#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
+#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(void*)(0))
+
+#define dtfirst(d) (*(_DT(d)->searchf))((d),(void*)(0),DT_FIRST)
+#define dtnext(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_NEXT)
+#define dtleast(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_SEARCH|DT_NEXT)
+#define dtlast(d) (*(_DT(d)->searchf))((d),(void*)(0),DT_LAST)
+#define dtprev(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_PREV)
+#define dtmost(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_SEARCH|DT_PREV)
+#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_SEARCH)
+#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_MATCH)
+#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_INSERT)
+#define dtappend(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_INSERT|DT_APPEND)
+#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_DELETE)
+#define dtattach(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_ATTACH)
+#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(void*)(o),DT_DETACH)
+#define dtclear(d) (*(_DT(d)->searchf))((d),(void*)(0),DT_CLEAR)
#define dtfound(d) (_DT(d)->type & DT_FOUND)
#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */
/* announce the close event to see if we should continue */
disc = dt->disc;
if(disc->eventf &&
- (ev = (*disc->eventf)(dt,DT_CLOSE,NIL(Void_t*),disc)) < 0)
+ (ev = (*disc->eventf)(dt,DT_CLOSE,NIL(void*),disc)) < 0)
return -1;
if(dt->view) /* turn off viewing */
dtview(dt,NIL(Dt_t*));
if(ev == 0) /* release all allocated data */
- { (void)(*(dt->meth->searchf))(dt,NIL(Void_t*),DT_CLEAR);
+ { (void)(*(dt->meth->searchf))(dt,NIL(void*),DT_CLEAR);
if(dtsize(dt) > 0)
return -1;
if(dt->data->ntab > 0)
- (*dt->memoryf)(dt,(Void_t*)dt->data->htab,0,disc);
- (*dt->memoryf)(dt,(Void_t*)dt->data,0,disc);
+ (*dt->memoryf)(dt,(void*)dt->data->htab,0,disc);
+ (*dt->memoryf)(dt,(void*)dt->data,0,disc);
}
if(dt->type == DT_MALLOC)
- free((Void_t*)dt);
+ free((void*)dt);
else if(ev == 0 && dt->type == DT_MEMORYF)
- (*dt->memoryf)(dt, (Void_t*)dt, 0, disc);
+ (*dt->memoryf)(dt, (void*)dt, 0, disc);
if(disc->eventf)
- (void)(*disc->eventf)(dt, DT_ENDCLOSE, NIL(Void_t*), disc);
+ (void)(*disc->eventf)(dt, DT_ENDCLOSE, NIL(void*), disc);
return 0;
}
** Written by Kiem-Phong Vo (5/26/96)
*/
-static Void_t* dtmemory(Dt_t* dt,Void_t* addr,size_t size,Dtdisc_t* disc)
+static void* dtmemory(Dt_t* dt,void* addr,size_t size,Dtdisc_t* disc)
{
if(addr)
{ if(size == 0)
{ free(addr);
- return NIL(Void_t*);
+ return NIL(void*);
}
else return realloc(addr,size);
}
- else return size > 0 ? malloc(size) : NIL(Void_t*);
+ else return size > 0 ? malloc(size) : NIL(void*);
}
Dtdisc_t* dtdisc(Dt_t* dt, Dtdisc_t* disc, int type)
UNFLATTEN(dt);
- if(old->eventf && (*old->eventf)(dt,DT_DISC,(Void_t*)disc,old) < 0)
+ if(old->eventf && (*old->eventf)(dt,DT_DISC,(void*)disc,old) < 0)
return NIL(Dtdisc_t*);
dt->disc = disc;
{ t = r->right;
if(!(type&DT_SAMEHASH)) /* new hash value */
{ k = (char*)_DTOBJ(r,disc->link);
- k = _DTKEY((Void_t*)k,disc->key,disc->size);
+ k = _DTKEY((void*)k,disc->key,disc->size);
r->hash = _DTHSH(dt,k,disc,disc->size);
}
- (void)(*searchf)(dt,(Void_t*)r,DT_RENEW);
+ (void)(*searchf)(dt,(void*)r,DT_RENEW);
r = t;
}
}
}
}
-static Void_t* dthash(Dt_t* dt, reg Void_t* obj, int type)
+static void* dthash(Dt_t* dt, reg void* obj, int type)
{
reg Dtlink_t *t, *r = NULL, *p;
- reg Void_t *k, *key;
+ reg void *k, *key;
reg uint hsh;
reg int lk, sz, ky;
reg Dtcompar_f cmpf;
goto end_walk;
if(dt->data->size <= 0 || !(type&(DT_CLEAR|DT_FIRST|DT_LAST)) )
- return NIL(Void_t*);
+ return NIL(void*);
ends = (s = dt->data->htab) + dt->data->ntab;
if(type&DT_CLEAR)
if(disc->freef)
(*disc->freef)(dt,_DTOBJ(t,lk),disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)t,0,disc);
+ (*dt->memoryf)(dt,(void*)t,0,disc);
t = r;
}
}
dt->data->here = NIL(Dtlink_t*);
dt->data->size = 0;
dt->data->loop = 0;
- return NIL(Void_t*);
+ return NIL(void*);
}
else /* computing the first/last object */
{ t = NIL(Dtlink_t*);
dt->data->loop += 1;
dt->data->here = t;
- return t ? _DTOBJ(t,lk) : NIL(Void_t*);
+ return t ? _DTOBJ(t,lk) : NIL(void*);
}
}
/* allow apps to delete an object "actually" in the dictionary */
if(dt->meth->type == DT_BAG && (type&(DT_DELETE|DT_DETACH)) )
{ if(!dtsearch(dt,obj) )
- return NIL(Void_t*);
+ return NIL(void*);
s = dt->data->htab + HINDEX(dt->data->ntab,dt->data->here->hash);
r = NIL(Dtlink_t*);
if(type&(DT_MATCH|DT_SEARCH|DT_VSEARCH))
{ if(!t)
- return NIL(Void_t*);
+ return NIL(void*);
if(p && (dt->data->type&DT_SET) && dt->data->loop <= 0)
{ /* move-to-front heuristic */
p->right = t->right;
if(disc->makef && (type&DT_INSERT) &&
!(obj = (*disc->makef)(dt,obj,disc)) )
- return NIL(Void_t*);
+ return NIL(void*);
if(lk >= 0)
r = _DTLNK(obj,lk);
else
{ r = (Dtlink_t*)(*dt->memoryf)
- (dt,NIL(Void_t*),sizeof(Dthold_t),disc);
+ (dt,NIL(void*),sizeof(Dthold_t),disc);
if(r)
((Dthold_t*)r)->obj = obj;
else
{ if(disc->makef && disc->freef && (type&DT_INSERT))
(*disc->freef)(dt,obj,disc);
- return NIL(Void_t*);
+ return NIL(void*);
}
}
r->hash = hsh;
if(disc->freef && (type&DT_INSERT))
(*disc->freef)(dt,obj,disc);
if(disc->link < 0)
- (*disc->memoryf)(dt,(Void_t*)r,0,disc);
- return NIL(Void_t*);
+ (*disc->memoryf)(dt,(void*)r,0,disc);
+ return NIL(void*);
}
s = dt->data->htab + HINDEX(dt->data->ntab,hsh);
if(t)
dt->data->loop = 0;
if(dt->data->size > HLOAD(dt->data->ntab) && dt->data->loop <= 0)
dthtab(dt);
- return NIL(Void_t*);
+ return NIL(void*);
}
else
{ dt->data->type |= DT_WALK;
{ if(disc->freef)
(*disc->freef)(dt,obj,disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)r,0,disc);
- return t ? _DTOBJ(t,lk) : NIL(Void_t*);
+ (*dt->memoryf)(dt,(void*)r,0,disc);
+ return t ? _DTOBJ(t,lk) : NIL(void*);
}
}
else /*if(type&(DT_DELETE|DT_DETACH))*/
{ /* take an element out of the dictionary */
do_delete:
if(!t)
- return NIL(Void_t*);
+ return NIL(void*);
else if(p)
p->right = t->right;
else if((p = *s) == t)
if(disc->freef && (type&DT_DELETE))
(*disc->freef)(dt,obj,disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)t,0,disc);
+ (*dt->memoryf)(dt,(void*)t,0,disc);
return obj;
}
}
** Written by Kiem-Phong Vo (05/25/96)
*/
-static Void_t* dtlist(reg Dt_t* dt, reg Void_t* obj, reg int type)
+static void* dtlist(reg Dt_t* dt, reg void* obj, reg int type)
{
reg int lk, sz, ky;
reg Dtcompar_f cmpf;
reg Dtdisc_t* disc;
reg Dtlink_t *r, *t;
- reg Void_t *key, *k;
+ reg void *key, *k;
UNFLATTEN(dt);
disc = dt->disc; _DTDSC(disc,ky,sz,lk,cmpf);
r = r->left;
dt->data->here = r;
}
- return r ? _DTOBJ(r,lk) : NIL(Void_t*);
+ return r ? _DTOBJ(r,lk) : NIL(void*);
}
else if(type&(DT_DELETE|DT_DETACH))
{ if((dt->data->type&(DT_LIST|DT_DEQUE)) || !(r = dt->data->head))
- return NIL(Void_t*);
+ return NIL(void*);
else goto dt_delete;
}
else if(type&DT_CLEAR)
if(disc->freef)
(*disc->freef)(dt,_DTOBJ(r,lk),disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)r,0,disc);
+ (*dt->memoryf)(dt,(void*)r,0,disc);
}
}
dt->data->head = dt->data->here = NIL(Dtlink_t*);
dt->data->size = 0;
- return NIL(Void_t*);
+ return NIL(void*);
}
- else return NIL(Void_t*);
+ else return NIL(void*);
}
if(type&(DT_INSERT|DT_ATTACH))
{ if(disc->makef && (type&DT_INSERT) &&
!(obj = (*disc->makef)(dt,obj,disc)) )
- return NIL(Void_t*);
+ return NIL(void*);
if(lk >= 0)
r = _DTLNK(obj,lk);
else
{ r = (Dtlink_t*)(*dt->memoryf)
- (dt,NIL(Void_t*),sizeof(Dthold_t),disc);
+ (dt,NIL(void*),sizeof(Dthold_t),disc);
if(r)
((Dthold_t*)r)->obj = obj;
else
{ if(disc->makef && disc->freef && (type&DT_INSERT))
(*disc->freef)(dt,obj,disc);
- return NIL(Void_t*);
+ return NIL(void*);
}
}
}
if(!r)
- return NIL(Void_t*);
+ return NIL(void*);
dt->type |= DT_FOUND;
if(type&(DT_DELETE|DT_DETACH))
if(disc->freef && (type&DT_DELETE))
(*disc->freef)(dt,obj,disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)r,0,disc);
+ (*dt->memoryf)(dt,(void*)r,0,disc);
return obj;
}
else if(type&DT_NEXT)
r = r == dt->data->head ? NIL(Dtlink_t*) : r->left;
dt->data->here = r;
- return r ? _DTOBJ(r,lk) : NIL(Void_t*);
+ return r ? _DTOBJ(r,lk) : NIL(void*);
}
#ifndef KPVDEL /* to be remove next round */
return oldmeth;
if(disc->eventf &&
- (*disc->eventf)(dt,DT_METH,(Void_t*)meth,disc) < 0)
+ (*disc->eventf)(dt,DT_METH,(void*)meth,disc) < 0)
return NIL(Dtmethod_t*);
dt->data->minp = 0;
dt->data->head = NIL(Dtlink_t*);
else if(dt->data->type&(DT_SET|DT_BAG) )
{ if(dt->data->ntab > 0)
- (*dt->memoryf)(dt,(Void_t*)dt->data->htab,0,disc);
+ (*dt->memoryf)(dt,(void*)dt->data->htab,0,disc);
dt->data->ntab = 0;
dt->data->htab = NIL(Dtlink_t**);
}
{ dt->data->size = 0;
while(list)
{ r = list->right;
- (*meth->searchf)(dt,(Void_t*)list,DT_RENEW);
+ (*meth->searchf)(dt,(void*)list,DT_RENEW);
list = r;
}
}
while(list)
{ r = list->right;
if(rehash)
- { reg Void_t* key = _DTOBJ(list,disc->link);
+ { reg void* key = _DTOBJ(list,disc->link);
key = _DTKEY(key,disc->key,disc->size);
list->hash = _DTHSH(dt,key,disc,disc->size);
}
- (void)(*meth->searchf)(dt,(Void_t*)list,DT_RENEW);
+ (void)(*meth->searchf)(dt,(void*)list,DT_RENEW);
list = r;
}
}
dt->type = DT_MALLOC;
dt->nview = 0;
dt->view = dt->walk = NIL(Dt_t*);
- dt->user = NIL(Void_t*);
+ dt->user = NIL(void*);
if(disc->eventf)
{ /* if shared/persistent dictionary, get existing data */
data = NIL(Dtdata_t*);
- if((e = (*disc->eventf)(dt,DT_OPEN,(Void_t*)(&data),disc)) < 0)
+ if((e = (*disc->eventf)(dt,DT_OPEN,(void*)(&data),disc)) < 0)
goto err_open;
else if(e > 0)
{ if(data)
if(!disc->memoryf)
goto err_open;
- free((Void_t*)dt);
+ free((void*)dt);
if(!(dt = (*disc->memoryf)(0, 0, sizeof(Dt_t), disc)) )
return NIL(Dt_t*);
dt->searchf = NIL(Dtsearch_f);
}
/* allocate sharable data */
- if(!(data = (Dtdata_t*)(dt->memoryf)(dt,NIL(Void_t*),sizeof(Dtdata_t),disc)) )
+ if(!(data = (Dtdata_t*)(dt->memoryf)(dt,NIL(void*),sizeof(Dtdata_t),disc)) )
{ err_open:
- free((Void_t*)dt);
+ free((void*)dt);
return NIL(Dt_t*);
}
dt->meth = meth;
if(disc->eventf)
- (*disc->eventf)(dt, DT_ENDOPEN, (Void_t*)dt, disc);
+ (*disc->eventf)(dt, DT_ENDOPEN, (void*)dt, disc);
return dt;
}
** Written by Kiem-Phong Vo (5/25/96)
*/
-Void_t* dtrenew(Dt_t* dt, reg Void_t* obj)
+void* dtrenew(Dt_t* dt, reg void* obj)
{
- reg Void_t* key;
+ reg void* key;
reg Dtlink_t *e, *t, **s;
reg Dtdisc_t* disc = dt->disc;
UNFLATTEN(dt);
if(!(e = dt->data->here) || _DTOBJ(e,disc->link) != obj)
- return NIL(Void_t*);
+ return NIL(void*);
if(dt->data->type&(DT_STACK|DT_QUEUE|DT_LIST))
return obj;
}
dt->data->size -= 1;
- return (*dt->meth->searchf)(dt,(Void_t*)e,DT_RENEW) ? obj : NIL(Void_t*);
+ return (*dt->meth->searchf)(dt,(void*)e,DT_RENEW) ? obj : NIL(void*);
}
{ dt->data->size = 0;
while(list)
{ t = list->right;
- (*searchf)(dt,(Void_t*)list,DT_RENEW);
+ (*searchf)(dt,(void*)list,DT_RENEW);
list = t;
}
}
** Written by Kiem-Phong Vo (02/28/03)
*/
-uint dtstrhash(reg uint h, Void_t* args, reg int n)
+uint dtstrhash(reg uint h, void* args, reg int n)
{
reg unsigned char* s = (unsigned char*)args;
** Written by Kiem-Phong Vo (5/25/96)
*/
-static Void_t* dttree(Dt_t* dt, Void_t* obj, int type)
+static void* dttree(Dt_t* dt, void* obj, int type)
{
Dtlink_t *root, *t;
int cmp, lk, sz, ky;
- Void_t *o, *k, *key;
+ void *o, *k, *key;
Dtlink_t *l, *r, *me = NULL, link;
int n, minp, turn[DT_MINP];
Dtcompar_f cmpf;
root = dt->data->here;
if(!obj)
{ if(!root || !(type&(DT_CLEAR|DT_FIRST|DT_LAST)) )
- return NIL(Void_t*);
+ return NIL(void*);
if(type&DT_CLEAR) /* delete all objects */
{ if(disc->freef || disc->link < 0)
if(disc->freef)
(*disc->freef)(dt,_DTOBJ(root,lk),disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)root,0,disc);
+ (*dt->memoryf)(dt,(void*)root,0,disc);
} while((root = t) );
}
dt->data->size = 0;
dt->data->here = NIL(Dtlink_t*);
- return NIL(Void_t*);
+ return NIL(void*);
}
else /* computing largest/smallest element */
{ if(type&DT_LAST)
else
{ turn[n] = cmp;
if(!(t = cmp < 0 ? t->left : t->right) )
- return NIL(Void_t*);
+ return NIL(void*);
}
}
if(disc->freef && (type&DT_DELETE))
(*disc->freef)(dt,obj,disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)root,0,disc);
+ (*dt->memoryf)(dt,(void*)root,0,disc);
if((dt->data->size -= 1) < 0)
dt->data->size = -1;
goto no_root;
{ if(disc->freef)
(*disc->freef)(dt,obj,disc);
if(disc->link < 0)
- (*dt->memoryf)(dt,(Void_t*)me,0,disc);
+ (*dt->memoryf)(dt,(void*)me,0,disc);
}
else
{ me->left = NIL(Dtlink_t*);
r = t;
r->left = link.right;
dt->data->here = link.left;
- return (type&DT_DELETE) ? obj : NIL(Void_t*);
+ return (type&DT_DELETE) ? obj : NIL(void*);
}
else if(type&(DT_INSERT|DT_ATTACH))
{ dt_insert:
root = _DTLNK(obj,lk);
else
{ root = (Dtlink_t*)(*dt->memoryf)
- (dt,NIL(Void_t*),sizeof(Dthold_t),disc);
+ (dt,NIL(void*),sizeof(Dthold_t),disc);
if(root)
((Dthold_t*)root)->obj = obj;
else if(disc->makef && disc->freef &&
goto has_root;
}
else /*if(type&DT_DELETE)*/
- { obj = NIL(Void_t*);
+ { obj = NIL(void*);
goto no_root;
}
}
- return NIL(Void_t*);
+ return NIL(void*);
}
/* make this method available */
*/
-static Void_t* dtvsearch(Dt_t* dt, reg Void_t* obj, reg int type)
+static void* dtvsearch(Dt_t* dt, reg void* obj, reg int type)
{
Dt_t *d, *p;
- Void_t *o, *n, *ok, *nk;
+ void *o, *n, *ok, *nk;
int cmp, lk, sz, ky;
Dtcompar_f cmpf;
if(dt->meth->type & (DT_OBAG|DT_OSET) )
{ if(!(type & (DT_FIRST|DT_LAST|DT_NEXT|DT_PREV)) )
- return NIL(Void_t*);
+ return NIL(void*);
- n = nk = NIL(Void_t*); p = NIL(Dt_t*);
+ n = nk = NIL(void*); p = NIL(Dt_t*);
for(d = dt; d; d = d->view)
{ if(!(o = (*d->meth->searchf)(d, obj, type)) )
continue;
/* non-ordered methods */
if(!(type & (DT_NEXT|DT_PREV)) )
- return NIL(Void_t*);
+ return NIL(void*);
if(!dt->walk || obj != _DTOBJ(dt->walk->data->here, dt->walk->disc->link) )
{ for(d = dt; d; d = d->view)
break;
dt->walk = d;
if(!(obj = o) )
- return NIL(Void_t*);
+ return NIL(void*);
}
for(d = dt->walk, obj = (*d->meth->searchf)(d, obj, type);; )
}
if(!(d = dt->walk = d->view) ) /* move on to next dictionary */
- return NIL(Void_t*);
+ return NIL(void*);
else if(type&DT_NEXT)
- obj = (*(d->meth->searchf))(d,NIL(Void_t*),DT_FIRST);
- else obj = (*(d->meth->searchf))(d,NIL(Void_t*),DT_LAST);
+ obj = (*(d->meth->searchf))(d,NIL(void*),DT_FIRST);
+ else obj = (*(d->meth->searchf))(d,NIL(void*),DT_LAST);
}
}
** Written by Kiem-Phong Vo (5/25/96)
*/
-int dtwalk(reg Dt_t* dt, int (*userf)(Dt_t*, Void_t*, Void_t*), Void_t* data)
+int dtwalk(reg Dt_t* dt, int (*userf)(Dt_t*, void*, void*), void* data)
{
- reg Void_t *obj, *next;
+ reg void *obj, *next;
reg Dt_t* walk;
reg int rv;
#define __INLINE__ __inline
#endif
- /* Void_t is defined so that Void_t* can address any type */
- #ifndef Void_t
- #define Void_t void
- #endif /*Void_t*/
-
/* dynamic linked library external scope handling */
#undef extern
#if _dll_import && !defined(__EXPORT__) && _DLL_BLD
#define MINATTR 4 /* minimum allocation */
-static void freesym(Dict_t * d, Void_t * obj, Dtdisc_t * disc);
+static void freesym(Dict_t * d, void * obj, Dtdisc_t * disc);
Dtdisc_t AgDataDictDisc = {
(int) offsetof(Agsym_t, name), /* use symbol name as key */
agfree(g, attr->str);
}
-static void freesym(Dict_t * d, Void_t * obj, Dtdisc_t * disc)
+static void freesym(Dict_t * d, void * obj, Dtdisc_t * disc)
{
Agsym_t *sym;
void agdtdisc(Agraph_t * g, Dict_t * dict, Dtdisc_t * disc);
long agdtdelete(Agraph_t * g, Dict_t * dict, void *obj);
int agdtclose(Agraph_t * g, Dict_t * dict);
-void *agdictobjmem(Dict_t * dict, Void_t * p, size_t size,
+void *agdictobjmem(Dict_t * dict, void * p, size_t size,
Dtdisc_t * disc);
-void agdictobjfree(Dict_t * dict, Void_t * p, Dtdisc_t * disc);
+void agdictobjfree(Dict_t * dict, void * p, Dtdisc_t * disc);
/* name-value pair operations */
Agdatadict_t *agdatadict(Agraph_t * g, int cflag);
static Agraph_t *Ag_dictop_G;
/* only indirect call through dtopen() is expected */
-void *agdictobjmem(Dict_t * dict, Void_t * p, size_t size, Dtdisc_t * disc)
+void *agdictobjmem(Dict_t * dict, void * p, size_t size, Dtdisc_t * disc)
{
Agraph_t *g;
return NIL(void *);
}
-void agdictobjfree(Dict_t * dict, Void_t * p, Dtdisc_t * disc)
+void agdictobjfree(Dict_t * dict, void * p, Dtdisc_t * disc)
{
Agraph_t *g;
return (long) dtdelete(dict, obj);
}
-int agobjfinalize(Void_t * obj)
+int agobjfinalize(void * obj)
{
agfree(Ag_dictop_G, obj);
return 0;
#include <intset.h>
#include <memory.h>
-static Void_t*
+static void*
mkIntItem(Dt_t* d,intitem* obj,Dtdisc_t* disc)
{
intitem* np = NEW(intitem);
np->id = obj->id;
- return (Void_t*)np;
+ return (void*)np;
}
static void
return span->size;
}
-static Void_t* textfont_makef(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)
+static void* textfont_makef(Dt_t* dt, void* obj, Dtdisc_t* disc)
{
textfont_t *f1 = (textfont_t*)obj;
textfont_t *f2 = calloc(1,sizeof(textfont_t));
return f2;
}
-static void textfont_freef(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)
+static void textfont_freef(Dt_t* dt, void* obj, Dtdisc_t* disc)
{
textfont_t *f = (textfont_t*)obj;
free(f);
}
-static int textfont_comparf (Dt_t* dt, Void_t* key1, Void_t* key2, Dtdisc_t* disc)
+static int textfont_comparf (Dt_t* dt, void* key1, void* key2, Dtdisc_t* disc)
{
int rc;
textfont_t *f1 = (textfont_t*)key1, *f2 = (textfont_t*)key2;
}
}
-typedef int (*walkfn_t) (Dt_t *, Void_t *, Void_t *);
+typedef int (*walkfn_t) (Dt_t *, void *, void *);
/* walkGrid:
* Apply function walkf to each cell in the grid.
}
}
-static void usershape_close (Dict_t * dict, Void_t * p, Dtdisc_t * disc)
+static void usershape_close (Dict_t * dict, void * p, Dtdisc_t * disc)
{
usershape_t *us = (usershape_t *)p;
void *np;
} nsitem;
-static Void_t *makef(Dt_t * d, nsitem * obj, Dtdisc_t * disc)
+static void *makef(Dt_t * d, nsitem * obj, Dtdisc_t * disc)
{
nsitem *p;
extern int Verbose;
-static int icompare(Dt_t *, Void_t *, Void_t *, Dtdisc_t *);
+static int icompare(Dt_t *, void *, void *, Dtdisc_t *);
Dtdisc_t Hdisc = { offsetof(HDict_t, key), sizeof(int), -1, 0, 0,
icompare, 0, 0, 0
};
-static int icompare(Dt_t * dt, Void_t * v1, Void_t * v2, Dtdisc_t * disc)
+static int icompare(Dt_t * dt, void * v1, void * v2, Dtdisc_t * disc)
{
int k1 = *((int *) v1), k2 = *((int *) v2);
return k1 - k2;
{
int size=dtsize(xlp->hdx), freed=0;
while(dtsize(xlp->hdx) ) {
- Void_t*vp=dtfinger(xlp->hdx);
+ void*vp=dtfinger(xlp->hdx);
assert(vp);
if(vp) {
dtdetach(xlp->hdx, vp);
#define P2I(p) (Sfulong_t)((char*)(p) - (char*)0)
#ifdef HAVE_STRUCT_DIOATTR
-static ssize_t diordwr(Sfio_t * f, Void_t * buf, size_t n, Direct_t * di,
+static ssize_t diordwr(Sfio_t * f, void * buf, size_t n, Direct_t * di,
int type)
{
size_t rw, done;
if (rv > 0) {
rw -= rv;
done += rv;
- buf = (Void_t *) ((char *) buf + rv);
+ buf = (void *) ((char *) buf + rv);
}
if (rv < io || rw < di->dio.d_miniosz)
return done ? done : rv;
}
-static ssize_t dioread(Sfio_t * f, Void_t * buf, size_t n, Sfdisc_t * disc)
+static ssize_t dioread(Sfio_t * f, void * buf, size_t n, Sfdisc_t * disc)
{
return diordwr(f, buf, n, (Direct_t *) disc, SF_READ);
}
-static ssize_t diowrite(Sfio_t * f, const Void_t * buf, size_t n,
+static ssize_t diowrite(Sfio_t * f, const void * buf, size_t n,
Sfdisc_t * disc)
{
- return diordwr(f, (Void_t *) buf, n, (Direct_t *) disc, SF_WRITE);
+ return diordwr(f, (void *) buf, n, (Direct_t *) disc, SF_WRITE);
}
-static int dioexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
+static int dioexcept(Sfio_t * f, int type, void * data, Sfdisc_t * disc)
{
Direct_t *di = (Direct_t *) disc;
#else
int cntl;
struct dioattr dio;
- Void_t *buf;
+ void *buf;
Direct_t *di;
if (f->extent < 0 || (f->flags & SF_STRING))
if (!(di = (Direct_t *) malloc(sizeof(Direct_t))))
goto no_direct;
- if (!(buf = (Void_t *) memalign(dio.d_mem, bufsize))) {
+ if (!(buf = (void *) memalign(dio.d_mem, bufsize))) {
free(di);
goto no_direct;
}
* @param n number of bytes requested
* @param disc discipline
*/
-static ssize_t filterread(Sfio_t * f, Void_t * buf, size_t n,
+static ssize_t filterread(Sfio_t * f, void * buf, size_t n,
Sfdisc_t * disc)
{
Filter_t *fi;
* @param n number of bytes requested
* @param disc discipline
*/
-static ssize_t filterwrite(Sfio_t * f, const Void_t * buf, size_t n,
+static ssize_t filterwrite(Sfio_t * f, const void * buf, size_t n,
Sfdisc_t * disc)
{
return -1;
}
/* on close, remove the discipline */
-static int filterexcept(Sfio_t * f, int type, Void_t * data,
+static int filterexcept(Sfio_t * f, int type, void * data,
Sfdisc_t * disc)
{
if (type == SF_FINAL || type == SF_DPOP) {
return -1;
/* unbuffered so that write data will get to the pipe right away */
- sfsetbuf(filter, NIL(Void_t *), 0);
+ sfsetbuf(filter, NIL(void *), 0);
/* make the write descriptor nonblocking */
sfset(filter, SF_READ, 0);
}
-static int lzwExcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
+static int lzwExcept(Sfio_t * f, int type, void * data, Sfdisc_t * disc)
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
* with those of the compress() routine. See the definitions above.
*/
-ssize_t lzwRead(Sfio_t * f, Void_t * iobuf, size_t iocnt,
+ssize_t lzwRead(Sfio_t * f, void * iobuf, size_t iocnt,
Sfdisc_t * sfdisc)
{
LZW_Disc *disc = (LZW_Disc *) sfdisc;
}
-static ssize_t lzwWrite(Sfio_t * f, const Void_t * buf, size_t count,
+static ssize_t lzwWrite(Sfio_t * f, const void * buf, size_t count,
Sfdisc_t * disc)
{
return (ssize_t) (-1);
* @param n number of bytes to read
* @param disc discipline
*/
-static ssize_t skwrite(Sfio_t * f, const Void_t * buf, size_t n,
+static ssize_t skwrite(Sfio_t * f, const void * buf, size_t n,
Sfdisc_t * disc)
{
return (ssize_t) (-1);
* @param n number of bytes to read
* @param disc discipline
*/
-static ssize_t skread(Sfio_t * f, Void_t * buf, size_t n, Sfdisc_t * disc)
+static ssize_t skread(Sfio_t * f, void * buf, size_t n, Sfdisc_t * disc)
{
Seek_t *sk;
Sfio_t *sf;
}
/* on close, remove the discipline */
-static int skexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
+static int skexcept(Sfio_t * f, int type, void * data, Sfdisc_t * disc)
{
if (type == SF_FINAL || type == SF_DPOP) {
sfclose(((Seek_t *) disc)->shadow);
** Written by Glenn Fowler (03/18/1998).
*/
-static int slowexcept(Sfio_t * f, int type, Void_t * v, Sfdisc_t * disc)
+static int slowexcept(Sfio_t * f, int type, void * v, Sfdisc_t * disc)
{
NOTUSED(f);
NOTUSED(v);
Sfoff_t here; /* current seek location */
} Subfile_t;
-static ssize_t streamio(Sfio_t * f, Void_t * buf, size_t n,
+static ssize_t streamio(Sfio_t * f, void * buf, size_t n,
Sfdisc_t * disc, int type)
{
reg Subfile_t *su;
return io;
}
-static ssize_t streamwrite(Sfio_t * f, const Void_t * buf, size_t n,
+static ssize_t streamwrite(Sfio_t * f, const void * buf, size_t n,
Sfdisc_t * disc)
{
- return streamio(f, (Void_t *) buf, n, disc, SF_WRITE);
+ return streamio(f, (void *) buf, n, disc, SF_WRITE);
}
-static ssize_t streamread(Sfio_t * f, Void_t * buf, size_t n,
+static ssize_t streamread(Sfio_t * f, void * buf, size_t n,
Sfdisc_t * disc)
{
return streamio(f, buf, n, disc, SF_READ);
return (su->here = pos);
}
-static int streamexcept(Sfio_t * f, int type, Void_t * data,
+static int streamexcept(Sfio_t * f, int type, void * data,
Sfdisc_t * disc)
{
if (type == SF_FINAL || type == SF_DPOP)
* @param size the data size
* @param disc the tee discipline
*/
-static ssize_t teewrite(Sfio_t * f, const Void_t * buf, size_t size,
+static ssize_t teewrite(Sfio_t * f, const void * buf, size_t size,
Sfdisc_t * disc)
{
reg Tee_t *te = (Tee_t *) disc;
}
/* on close, remove the discipline */
-static int teeexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
+static int teeexcept(Sfio_t * f, int type, void * data, Sfdisc_t * disc)
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
* @param n number of bytes to read
* @param disc discipline
*/
-static ssize_t unwrite(Sfio_t * f, const Void_t * buf, size_t n,
+static ssize_t unwrite(Sfio_t * f, const void * buf, size_t n,
Sfdisc_t * disc)
{
return -1;
* @param n number of bytes to read
* @param disc discipline
*/
-static ssize_t unread(Sfio_t * f, Void_t * buf, size_t n, Sfdisc_t * disc)
+static ssize_t unread(Sfio_t * f, void * buf, size_t n, Sfdisc_t * disc)
{
reg Union_t *un;
reg ssize_t r, m;
}
/* on close, remove the discipline */
-static int unexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
+static int unexcept(Sfio_t * f, int type, void * data, Sfdisc_t * disc)
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
#define __INLINE__ __inline
#endif
- /* Void_t is defined so that Void_t* can address any type */
- #ifndef Void_t
- #define Void_t void
- #endif /*Void_t*/
-
/* dynamic linked library external scope handling */
#undef extern
#if _dll_import && !defined(__EXPORT__) && _DLL_BLD
int sfclose(reg Sfio_t * f)
{
reg int local, ex, rv;
- Void_t *data = NIL(Void_t *);
+ void *data = NIL(void *);
SFMTXSTART(f, -1);
/* raise discipline exceptions */
if (f->disc
&& (ex =
- SFRAISE(f, local ? SF_NEW : SF_CLOSING, NIL(Void_t *))) != 0)
+ SFRAISE(f, local ? SF_NEW : SF_CLOSING, NIL(void *))) != 0)
SFMTXRETURN(f, ex);
if (!local && f->pool) { /* remove from pool */
else
#endif
if (f->flags & SF_MALLOC)
- data = (Void_t *) f->data;
+ data = (void *) f->data;
f->data = NIL(uchar *);
f->size = -1;
}
if (!local) {
- if (f->disc && (ex = SFRAISE(f, SF_FINAL, NIL(Void_t *))) != 0) {
+ if (f->disc && (ex = SFRAISE(f, SF_FINAL, NIL(void *))) != 0) {
rv = ex;
goto done;
}
free(f);
else {
f->disc = NIL(Sfdisc_t *);
- f->stdio = NIL(Void_t *);
+ f->stdio = NIL(void *);
f->mode = SF_AVAIL;
}
}
* @param sign return sign
* @param format conversion format
*/
-char *_sfcvt(Void_t * dv, int n_digit, int *decpt, int *sign, int format)
+char *_sfcvt(void * dv, int n_digit, int *decpt, int *sign, int format)
{
reg char *sp;
reg long n, v;
disc = d->disc;
if (d->exceptf) {
SFOPEN(f, 0);
- if ((*(d->exceptf)) (f, SF_DPOP, (Void_t *) disc, d) < 0)
+ if ((*(d->exceptf)) (f, SF_DPOP, (void *) disc, d) < 0)
goto done;
SFLOCK(f, 0);
}
d = f->disc;
if (d && d->exceptf) {
SFOPEN(f, 0);
- if ((*(d->exceptf)) (f, SF_DPUSH, (Void_t *) disc, d) < 0)
+ if ((*(d->exceptf)) (f, SF_DPUSH, (void *) disc, d) < 0)
goto done;
SFLOCK(f, 0);
}
SETLOCAL(f);
f->bits &= ~SF_NULL; /* turn off /dev/null handling */
if ((f->bits & SF_MMAP) || (f->mode & SF_INIT))
- sfsetbuf(f, NIL(Void_t *), (size_t) SF_UNBOUND);
+ sfsetbuf(f, NIL(void *), (size_t) SF_UNBOUND);
else if (f->data == f->tiny)
- sfsetbuf(f, NIL(Void_t *), 0);
+ sfsetbuf(f, NIL(void *), 0);
else {
int flags = f->flags;
- sfsetbuf(f, (Void_t *) f->data, f->size);
+ sfsetbuf(f, (void *) f->data, f->size);
f->flags |= (flags & SF_MALLOC);
}
}
double d;
float f;
char c, *s, **sp;
- Void_t *vp;
+ void *vp;
Sffmt_t *ft;
} Argv_t;
((v) || (f)->extent < 0 || \
((f)->flags&(SF_SHARE|SF_APPENDWR|SF_WHOLE)) ) )
#define SFSK(f,a,o,d) (SETLOCAL(f),sfsk(f,(Sfoff_t)a,o,d))
-#define SFRD(f,b,n,d) (SETLOCAL(f),sfrd(f,(Void_t*)b,n,d))
-#define SFWR(f,b,n,d) (SETLOCAL(f),sfwr(f,(Void_t*)b,n,d))
+#define SFRD(f,b,n,d) (SETLOCAL(f),sfrd(f,(void*)b,n,d))
+#define SFWR(f,b,n,d) (SETLOCAL(f),sfwr(f,(void*)b,n,d))
#define SFSYNC(f) (SETLOCAL(f),sfsync(f))
#define SFCLOSE(f) (SETLOCAL(f),sfclose(f))
#define SFFLSBUF(f,n) (SETLOCAL(f),_sfflsbuf(f,n))
/* note that MEMCPY advances the associated pointers */
#define MEMCPY(to,fr,n) \
switch(n) \
- { default : memcpy((Void_t*)to,(Void_t*)fr,n); to += n; fr += n; break; \
+ { default : memcpy((void*)to,(void*)fr,n); to += n; fr += n; break; \
case 7 : *to++ = *fr++; \
case 6 : *to++ = *fr++; \
case 5 : *to++ = *fr++; \
}
#define MEMSET(s,c,n) \
switch(n) \
- { default : memset((Void_t*)s,(int)c,n); s += n; break; \
+ { default : memset((void*)s,(int)c,n); s += n; break; \
case 7 : *s++ = c; \
case 6 : *s++ = c; \
case 5 : *s++ = c; \
extern int _sfexcept(Sfio_t *, int, ssize_t, Sfdisc_t *);
extern Sfrsrv_t *_sfrsrv(Sfio_t *, ssize_t);
extern int _sfsetpool(Sfio_t *);
- extern char *_sfcvt(Void_t *, int, int *, int *, int);
+ extern char *_sfcvt(void *, int, int *, int *, int);
extern char **_sfgetpath(char *);
extern Sfdouble_t _sfstrtod(const char *, char **);
#endif
#if !defined(_hdr_mman) && !_sys_mman
- extern Void_t *mmap(Void_t *, size_t, int, int, int, off_t);
- extern int munmap(Void_t *, size_t);
+ extern void *mmap(void *, size_t, int, int, int, off_t);
+ extern int munmap(void *, size_t);
#endif
#if !defined(_PACKAGE_ast)
typedef struct _sfdisc_s Sfdisc_t;
typedef ssize_t(*Sfread_f)
- (Sfio_t *, Void_t *, size_t, Sfdisc_t *);
+ (Sfio_t *, void *, size_t, Sfdisc_t *);
typedef ssize_t(*Sfwrite_f)
- (Sfio_t *, const Void_t *, size_t, Sfdisc_t *);
+ (Sfio_t *, const void *, size_t, Sfdisc_t *);
typedef Sfoff_t(*Sfseek_f) (Sfio_t *, Sfoff_t, int, Sfdisc_t *);
- typedef int (*Sfexcept_f) (Sfio_t *, int, Void_t *, Sfdisc_t *);
+ typedef int (*Sfexcept_f) (Sfio_t *, int, void *, Sfdisc_t *);
/* discipline structure */
struct _sfdisc_s {
/* formatting environment */
typedef struct _sffmt_s Sffmt_t;
- typedef int (*Sffmtext_f)(Sfio_t *, Void_t *, Sffmt_t *);
- typedef int (*Sffmtevent_f)(Sfio_t *, int, Void_t *, Sffmt_t *);
+ typedef int (*Sffmtext_f)(Sfio_t *, void *, Sffmt_t *);
+ typedef int (*Sffmtevent_f)(Sfio_t *, int, void *, Sffmt_t *);
struct _sffmt_s {
long version; /* version of this structure */
Sffmtext_f extf; /* function to process arguments */
char *t_str; /* type string */
ssize_t n_str; /* length of t_str */
- Void_t *noop; /* as yet unused */
+ void *noop; /* as yet unused */
};
#define sffmtversion(fe,type) \
(type ? ((fe)->version = SFIO_VERSION) : (fe)->version)
#define extern __EXPORT__
#endif
- extern Sfio_t *sfnew(Sfio_t *, Void_t *, size_t, int, int);
+ extern Sfio_t *sfnew(Sfio_t *, void *, size_t, int, int);
extern Sfio_t *sfopen(Sfio_t *, const char *, const char *);
extern Sfio_t *sfpopen(Sfio_t *, const char *, const char *);
extern Sfio_t *sfstack(Sfio_t *, Sfio_t *);
extern Sfio_t *sftmp(size_t);
extern int sfpurge(Sfio_t *);
extern int sfpoll(Sfio_t **, int, int);
- extern Void_t *sfreserve(Sfio_t *, ssize_t, int);
+ extern void *sfreserve(Sfio_t *, ssize_t, int);
extern int sfsync(Sfio_t *);
extern int sfclrlock(Sfio_t *);
- extern Void_t *sfsetbuf(Sfio_t *, Void_t *, size_t);
+ extern void *sfsetbuf(Sfio_t *, void *, size_t);
extern Sfdisc_t *sfdisc(Sfio_t *, Sfdisc_t *);
- extern int sfraise(Sfio_t *, int, Void_t *);
+ extern int sfraise(Sfio_t *, int, void *);
extern int sfnotify(void (*)(Sfio_t *, int, int));
extern int sfset(Sfio_t *, int, int);
extern int sfsetfd(Sfio_t *, int);
extern Sfio_t *sfpool(Sfio_t *, Sfio_t *, int);
- extern ssize_t sfread(Sfio_t *, Void_t *, size_t);
- extern ssize_t sfwrite(Sfio_t *, const Void_t *, size_t);
+ extern ssize_t sfread(Sfio_t *, void *, size_t);
+ extern ssize_t sfwrite(Sfio_t *, const void *, size_t);
extern Sfoff_t sfmove(Sfio_t *, Sfio_t *, Sfoff_t, int);
extern int sfclose(Sfio_t *);
extern Sfoff_t sftell(Sfio_t *);
extern int sfmutex(Sfio_t *, int);
/* io functions with discipline continuation */
- extern ssize_t sfrd(Sfio_t *, Void_t *, size_t, Sfdisc_t *);
- extern ssize_t sfwr(Sfio_t *, const Void_t *, size_t, Sfdisc_t *);
+ extern ssize_t sfrd(Sfio_t *, void *, size_t, Sfdisc_t *);
+ extern ssize_t sfwr(Sfio_t *, const void *, size_t, Sfdisc_t *);
extern Sfoff_t sfsk(Sfio_t *, Sfoff_t, int, Sfdisc_t *);
- extern ssize_t sfpkrd(int, Void_t *, size_t, int, long, int);
+ extern ssize_t sfpkrd(int, void *, size_t, int, long, int);
/* portable handling of primitive types */
extern int sfdlen(Sfdouble_t);
struct _sfpool_s* pool; /* the pool containing this */ \
struct _sfrsrv_s* rsrv; /* reserved buffer */ \
struct _sfproc_s* proc; /* coprocess id, etc. */ \
- Void_t* mutex; /* mutex for thread-safety */ \
- Void_t* stdio; /* stdio FILE if any */ \
+ void* mutex; /* mutex for thread-safety */ \
+ void* stdio; /* stdio FILE if any */ \
Sfoff_t lpos; /* last seek position */ \
size_t iosz; /* prefer size for I/O */
(struct _sfrsrv_s*)0, /* rsrv */ \
(struct _sfproc_s*)0, /* proc */ \
(mutex), /* mutex */ \
- (Void_t*)0, /* stdio */ \
+ (void*)0, /* stdio */ \
(Sfoff_t)0, /* lpos */ \
(size_t)0 /* iosz */ \
}
(f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \
(f)->proc = (struct _sfproc_s*)0, /* proc */ \
(f)->mutex = (mtx), /* mutex */ \
- (f)->stdio = (Void_t*)0, /* stdio */ \
+ (f)->stdio = (void*)0, /* stdio */ \
(f)->lpos = (Sfoff_t)0, /* lpos */ \
(f)->iosz = (size_t)0 /* iosz */ \
)
SFMTXLOCK(f);
/* let application know that we are leaving */
- (void) SFRAISE(f, SF_ATEXIT, NIL(Void_t *));
+ (void) SFRAISE(f, SF_ATEXIT, NIL(void *));
if (f->flags & SF_STRING)
continue;
(void) _sfmode(f, SF_WRITE, 1);
if (((f->bits & SF_MMAP) && f->data) ||
((f->mode & SF_WRITE) && f->next == f->data))
- (void) SFSETBUF(f, NIL(Void_t *), 0);
+ (void) SFSETBUF(f, NIL(void *), 0);
f->mode |= pool;
SFMTXUNLOCK(f);
goto done;
/* move old array to new one */
- memcpy((Void_t *) array, (Void_t *) p->sf,
+ memcpy((void *) array, (void *) p->sf,
p->n_sf * sizeof(Sfio_t *));
if (p->sf != p->array)
- free((Void_t *) p->sf);
+ free((void *) p->sf);
p->sf = array;
p->s_sf = n;
}
}
if (p->ndata > 0)
- memcpy((Void_t *) p->rdata, (Void_t *) f->next, p->ndata);
+ memcpy((void *) p->rdata, (void *) f->next, p->ndata);
f->endb = f->data;
} else { /* restore read data */
if (p->ndata > f->size) /* may lose data!!! */
p->ndata = f->size;
if (p->ndata > 0) {
- memcpy((Void_t *) f->data, (Void_t *) p->rdata, p->ndata);
+ memcpy((void *) f->data, (void *) p->rdata, p->ndata);
f->endb = f->data + p->ndata;
p->ndata = 0;
}
f->mode &= ~SF_GETR;
#ifdef MAP_TYPE
if ((f->bits & SF_MMAP) && (f->tiny[0] += 1) >= (4 * SF_NMAP)) { /* turn off mmap to avoid page faulting */
- sfsetbuf(f, (Void_t *) f->tiny, (size_t) SF_UNBOUND);
+ sfsetbuf(f, (void *) f->tiny, (size_t) SF_UNBOUND);
f->tiny[0] = 0;
} else
#endif
if (f->bits & SF_MMAP) {
if (f->data)
SFMUNMAP(f, f->data, f->endb - f->data);
- (void) SFSETBUF(f, (Void_t *) f->tiny, (size_t) SF_UNBOUND);
+ (void) SFSETBUF(f, (void *) f->tiny, (size_t) SF_UNBOUND);
}
#endif
if (f->data == f->tiny) {
goto done_filbuf;
else if (n > 1 && !fr->disc) {
r = sfpkrd(fr->file,
- (Void_t *) fr->data,
+ (void *) fr->data,
fr->size, rc, -1, (int) (-n));
if (r <= 0)
goto one_r;
r = cp - next;
if (fr->mode & SF_PKRD) { /* advance the read point by proper amount */
fr->mode &= ~SF_PKRD;
- (void) read(fr->file, (Void_t *) next, r);
+ (void) read(fr->file, (void *) next, r);
fr->here += r;
if (!direct)
fr->endb = cp;
else if ((w = endb - cp) > 0) { /* move left-over to read stream */
if (w > fr->size)
w = fr->size;
- memcpy((Void_t *) fr->data, (Void_t *) cp, w);
+ memcpy((void *) fr->data, (void *) cp, w);
fr->endb = fr->data + w;
if ((w = endb - (cp + w)) > 0)
(void) SFSK(fr, (Sfoff_t) (-w), SEEK_CUR, fr->disc);
if (direct == SF_WRITE)
fw->next += r;
else if (r <= (fw->endb - fw->next)) {
- memcpy((Void_t *) fw->next, (Void_t *) next, r);
+ memcpy((void *) fw->next, (void *) next, r);
fw->next += r;
- } else if ((w = SFWRITE(fw, (Void_t *) next, r)) != r) { /* a write error happened */
+ } else if ((w = SFWRITE(fw, (void *) next, r)) != r) { /* a write error happened */
if (w > 0) {
r -= w;
if (rc < 0)
* @param file file descriptor to read/write from
* @param flags type of file stream
*/
-Sfio_t *sfnew(Sfio_t * oldf, Void_t * buf, size_t size, int file,
+Sfio_t *sfnew(Sfio_t * oldf, void * buf, size_t size, int file,
int flags)
{
reg Sfio_t *f;
if (f->data
&& ((flags & SF_STRING) || size != (size_t) SF_UNBOUND)) {
if (sflags & SF_MALLOC)
- free((Void_t *) f->data);
+ free((void *) f->data);
f->data = NIL(uchar *);
}
if (!f->data)
}
for (;;) { /* hard write of data */
- if ((p = SFWRITE(f, (Void_t *) ps, p)) <= 0 || (n -= p) <= 0) {
+ if ((p = SFWRITE(f, (void *) ps, p)) <= 0 || (n -= p) <= 0) {
w -= n;
goto done;
}
* <0: no peeking, if rc>=0, get -action records,
* =0: no peeking, if rc>=0, must get a single record
*/
-ssize_t sfpkrd(int fd, Void_t * argbuf, size_t n, int rc, long tm,
+ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm,
int action)
{
reg ssize_t r;
break;
}
- free((Void_t *) fds);
+ free((void *) fds);
}
#endif /*_lib_poll*/
if (status[c] <= 0)
continue;
if ((d = fa[c]->disc) && d->exceptf) {
- if ((r = (*d->exceptf) (fa[c], SF_READY, (Void_t *) 0, d)) < 0)
+ if ((r = (*d->exceptf) (fa[c], SF_READY, (void *) 0, d)) < 0)
goto done;
else if (r > 0)
goto retry;
}
done:
- free((Void_t *) status);
+ free((void *) status);
return r;
}
POOLMTXSTART(p);
if (p->s_sf && p->sf != p->array)
- free((Void_t *) p->sf);
+ free((void *) p->sf);
p->mode = SF_AVAIL;
POOLMTXRETURN(p, 0);
av[3] = 0;
if (!(proc = procopen(0, av, 0, 0, flags)))
return 0;
- if (!(f = sfnew(f, NIL(Void_t *), (size_t) SF_UNBOUND,
+ if (!(f = sfnew(f, NIL(void *), (size_t) SF_UNBOUND,
(sflags & SF_READ) ? proc->rfd : proc->wfd, sflags)) ||
((f->bits |= bits),
_sfpopen(f, (sflags & SF_READ) ? proc->wfd : -1, proc->pid)) < 0)
/* make the streams */
if (!
(f =
- sfnew(f, NIL(Void_t *), (size_t) SF_UNBOUND, parent[pkeep],
+ sfnew(f, NIL(void *), (size_t) SF_UNBOUND, parent[pkeep],
sflags)))
goto error;
CLOSE(parent[!pkeep]);
SFMTXRETURN(f, -1);
if ((f->flags & SF_IOCHECK) && f->disc && f->disc->exceptf)
- (void) (*f->disc->exceptf) (f, SF_PURGE, (Void_t *) ((int) 1),
+ (void) (*f->disc->exceptf) (f, SF_PURGE, (void *) ((int) 1),
f->disc);
if (f->disc == _Sfudisc)
done:
if ((f->flags & SF_IOCHECK) && f->disc && f->disc->exceptf)
- (void) (*f->disc->exceptf) (f, SF_PURGE, (Void_t *) ((int) 0),
+ (void) (*f->disc->exceptf) (f, SF_PURGE, (void *) ((int) 0),
f->disc);
SFMTXRETURN(f, 0);
/* write out coded bytes */
n = ends - s + 1;
- w = SFWRITE(f, (Void_t *) s, n) == n ? w + n : -1;
+ w = SFWRITE(f, (void *) s, n) == n ? w + n : -1;
SFOPEN(f, 0);
SFMTXRETURN(f, w);
n = (ps - s) + 1;
if (n > 8 || SFWPEEK(f, ps, p) < n)
- n = SFWRITE(f, (Void_t *) s, n); /* write the hard way */
+ n = SFWRITE(f, (void *) s, n); /* write the hard way */
else {
switch (n) {
case 8:
n = (ps - s) + 1;
if (n > 8 || SFWPEEK(f, ps, p) < n)
- n = SFWRITE(f, (Void_t *) s, n); /* write the hard way */
+ n = SFWRITE(f, (void *) s, n); /* write the hard way */
else {
switch (n) {
case 8:
if (n > w)
n = w;
f->next -= n;
- (void) SFWRITE(f, (Void_t *) f->next, n);
+ (void) SFWRITE(f, (void *) f->next, n);
}
SFOPEN(f, 0);
n = (ps - s) + 1;
if (n > 8 || SFWPEEK(f, ps, p) < n)
- n = SFWRITE(f, (Void_t *) s, n); /* write the hard way */
+ n = SFWRITE(f, (void *) s, n); /* write the hard way */
else {
switch (n) {
case 8:
* @param data associated data
* @param
*/
-int sfraise(Sfio_t * f, int type, Void_t * data)
+int sfraise(Sfio_t * f, int type, void * data)
{
reg Sfdisc_t *disc, *next, *d;
reg int local, rv;
}
}
-ssize_t sfrd(reg Sfio_t * f, reg Void_t * buf, reg size_t n,
+ssize_t sfrd(reg Sfio_t * f, reg void * buf, reg size_t n,
Sfdisc_t * disc)
{
Sfoff_t r;
(void) SFSK(f, f->here, SEEK_SET, dc);
/* make a buffer */
- (void) SFSETBUF(f, (Void_t *) f->tiny,
+ (void) SFSETBUF(f, (void *) f->tiny,
(size_t) SF_UNBOUND);
if (!buf) {
- buf = (Void_t *) f->data;
+ buf = (void *) f->data;
n = f->size;
}
}
* @param n number of bytes to be read
* @param
*/
-ssize_t sfread(reg Sfio_t * f, Void_t * buf, reg size_t n)
+ssize_t sfread(reg Sfio_t * f, void * buf, reg size_t n)
{
reg uchar *s, *begs;
reg ssize_t r;
* @param size size of peek
* @param type LOCKR: lock stream, LASTR: last record
*/
-Void_t *sfreserve(reg Sfio_t * f, ssize_t size, int type)
+void *sfreserve(reg Sfio_t * f, ssize_t size, int type)
{
reg ssize_t n, sz;
reg Sfrsrv_t *rsrv;
- reg Void_t *data;
+ reg void *data;
reg int mode;
- SFMTXSTART(f, NIL(Void_t *));
+ SFMTXSTART(f, NIL(void *));
/* initialize io states */
rsrv = NIL(Sfrsrv_t *);
if ((rsrv = f->rsrv) && (n = -rsrv->slen) > 0) {
rsrv->slen = 0;
_Sfi = f->val = n;
- SFMTXRETURN(f, (Void_t *) rsrv->data);
+ SFMTXRETURN(f, (void *) rsrv->data);
} else
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
}
if (type > 0 && !(type == SF_LOCKR || type == 1))
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
if ((sz = size) == 0 && type != 0) { /* only return the current status and possibly lock stream */
if ((f->mode & SF_RDWR) != f->mode && _sfmode(f, 0, 0) < 0)
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
SFLOCK(f, 0);
if ((n = f->endb - f->next) < 0)
n = sz;
} else { /*if(f->mode&SF_READ) */
if (type <= 0 && (rsrv = _sfrsrv(f, sz)) &&
- (n = SFREAD(f, (Void_t *) rsrv->data, sz)) < sz)
+ (n = SFREAD(f, (void *) rsrv->data, sz)) < sz)
rsrv->slen = -n;
}
}
SFOPEN(f, 0);
if ((sz > 0 && n < sz) || (n == 0 && type <= 0))
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
- if ((data = rsrv ? (Void_t *) rsrv->data : (Void_t *) f->next)) {
+ if ((data = rsrv ? (void *) rsrv->data : (void *) f->next)) {
if (type > 0) {
f->mode |= SF_PEEK;
f->endr = f->endw = f->data;
- } else if (data == (Void_t *) f->next)
+ } else if (data == (void *) f->next)
f->next += (size >= 0 ? size : n);
}
if (f->extent >= size) {
if ((f->flags & SF_MALLOC) && (f->next - f->data) <= size) {
size_t s = (((size_t) size + 1023) / 1024) * 1024;
- Void_t *d;
+ void *d;
if (s < f->size && (d = realloc(f->data, s))) {
f->data = d;
f->size = s;
if (f->bits & SF_MMAP) { /* if mmap is not great, stop mmaping if moving around too much */
#if _mmap_worthy < 2
if ((f->next - f->data) < ((f->endb - f->data) / 4)) {
- SFSETBUF(f, (Void_t *) f->tiny, (size_t) SF_UNBOUND);
+ SFSETBUF(f, (void *) f->tiny, (size_t) SF_UNBOUND);
hardseek = 1; /* this forces a hard seek below */
} else
#endif
* @param buf new buffer
* @param size buffer size, -1 for default size
*/
-Void_t *sfsetbuf(reg Sfio_t * f, reg Void_t * buf, reg size_t size)
+void *sfsetbuf(reg Sfio_t * f, reg void * buf, reg size_t size)
{
reg int sf_malloc;
reg uchar *obuf;
SFONCE();
- SFMTXSTART(f, NIL(Void_t *));
+ SFMTXSTART(f, NIL(void *));
GETLOCAL(f, local);
if (size == 0 && buf) { /* special case to get buffer info */
_Sfi = f->val =
(f->bits & SF_MMAP) ? (f->endb - f->data) : f->size;
- SFMTXRETURN(f, (Void_t *) f->data);
+ SFMTXRETURN(f, (void *) f->data);
}
/* cleanup actions already done, don't allow write buffering any more */
if (_Sfexiting && !(f->flags & SF_STRING) && (f->mode & SF_WRITE)) {
- buf = NIL(Void_t *);
+ buf = NIL(void *);
size = 0;
}
if ((init = f->mode & SF_INIT)) {
if (!f->pool && _sfsetpool(f) < 0)
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
} else if ((f->mode & SF_RDWR) != SFMODE(f, local)
&& _sfmode(f, 0, local) < 0)
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
if (init)
f->mode = (f->mode & SF_RDWR) | SF_LOCK;
/* make sure there is no hidden read data */
if (f->proc && (f->flags & SF_READ) && (f->mode & SF_WRITE) &&
_sfmode(f, SF_READ, local) < 0)
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
/* synchronize first */
SFLOCK(f, local);
rv = SFSYNC(f);
SFOPEN(f, local);
if (rv < 0)
- SFMTXRETURN(f, NIL(Void_t *));
+ SFMTXRETURN(f, NIL(void *));
/* turn off the SF_SYNCED bit because buffer is changing */
f->mode &= ~SF_SYNCED;
else if ((ssize_t) (size = _Sfpage) < blksize)
size = blksize;
- buf = NIL(Void_t *);
+ buf = NIL(void *);
}
sf_malloc = 0;
if (size > 0 && !buf && !(f->bits & SF_MMAP)) { /* try to allocate a buffer */
if (obuf && size == (size_t) osize && init) {
- buf = (Void_t *) obuf;
+ buf = (void *) obuf;
obuf = NIL(uchar *);
sf_malloc = (oflags & SF_MALLOC);
}
if (!buf) { /* do allocation */
while (!buf && size > 0) {
- if ((buf = (Void_t *) malloc(size)))
+ if ((buf = (void *) malloc(size)))
break;
else
size /= 2;
if (size == 0 && !(f->flags & SF_STRING) && !(f->bits & SF_MMAP) && (f->mode & SF_READ)) { /* use the internal buffer */
size = sizeof(f->tiny);
- buf = (Void_t *) f->tiny;
+ buf = (void *) f->tiny;
}
/* set up new buffer */
f->flags = (f->flags & ~SF_MALLOC) | sf_malloc;
if (obuf && obuf != f->data && osize > 0 && (oflags & SF_MALLOC)) {
- free((Void_t *) obuf);
+ free((void *) obuf);
obuf = NIL(uchar *);
}
SFOPEN(f, local);
- SFMTXRETURN(f, (Void_t *) obuf);
+ SFMTXRETURN(f, (void *) obuf);
}
f2flags = f2->flags;
/* swap image and pool entries */
- memcpy((Void_t *) (&tmp), (Void_t *) f1, sizeof(Sfio_t));
- memcpy((Void_t *) f1, (Void_t *) f2, sizeof(Sfio_t));
- memcpy((Void_t *) f2, (Void_t *) (&tmp), sizeof(Sfio_t));
+ memcpy((void *) (&tmp), (void *) f1, sizeof(Sfio_t));
+ memcpy((void *) f1, (void *) f2, sizeof(Sfio_t));
+ memcpy((void *) f2, (void *) (&tmp), sizeof(Sfio_t));
if (f2pool >= 0)
f1->pool->sf[f2pool] = f1;
if (f1pool >= 0)
for (; f; f = f->push) {
if ((f->flags & SF_IOCHECK) && f->disc && f->disc->exceptf)
- (void) (*f->disc->exceptf) (f, SF_SYNC, (Void_t *) ((int) 1),
+ (void) (*f->disc->exceptf) (f, SF_SYNC, (void *) ((int) 1),
f->disc);
SFLOCK(f, local);
SFOPEN(f, local);
if ((f->flags & SF_IOCHECK) && f->disc && f->disc->exceptf)
- (void) (*f->disc->exceptf) (f, SF_SYNC, (Void_t *) ((int) 0),
+ (void) (*f->disc->exceptf) (f, SF_SYNC, (void *) ((int) 0),
f->disc);
}
memcpy(ft, &fp[n].ft, sizeof(Sffmt_t));
va_copy(ft->args, args);
ft->flags |= SFFMT_ARGPOS;
- v = (*ft->extf) (f, (Void_t *) (&fp[n].argv), ft);
+ v = (*ft->extf) (f, (void *) (&fp[n].argv), ft);
va_copy(args, ft->args);
memcpy(&fp[n].ft, ft, sizeof(Sffmt_t));
if (v < 0) {
if (ft)
memcpy(&savft, ft, sizeof(Sffmt_t));
} else if (type > 0) /* from sfvscanf */
- fp[n].argv.vp = va_arg(args, Void_t *);
+ fp[n].argv.vp = va_arg(args, void *);
else
switch (_Sftype[fp[n].ft.fmt]) {
case SFFMT_INT:
fp[n].argv.d = va_arg(args, double);
break;
case SFFMT_POINTER:
- fp[n].argv.vp = va_arg(args, Void_t *);
+ fp[n].argv.vp = va_arg(args, void *);
break;
case SFFMT_BYTE:
if (fp[n].ft.base >= 0)
static File_t *File; /* list pf temp files */
-static int _tmprmfile(Sfio_t * f, int type, Void_t * val, Sfdisc_t * disc)
+static int _tmprmfile(Sfio_t * f, int type, void * val, Sfdisc_t * disc)
{
reg File_t *ff, *last;
while (remove(ff->name) < 0 && errno == EINTR)
errno = 0;
- free((Void_t *) ff);
+ free((void *) ff);
}
vtmtxunlock(_Sfmutex);
}
vtmtxlock(_Sfmutex);
for (ff = File; ff; ff = next) {
next = ff->next;
- _tmprmfile(ff->f, SF_CLOSING, NIL(Void_t *), ff->f->disc);
+ _tmprmfile(ff->f, SF_CLOSING, NIL(void *), ff->f->disc);
}
vtmtxunlock(_Sfmutex);
}
return fd;
}
-static int _tmpexcept(Sfio_t * f, int type, Void_t * val, Sfdisc_t * disc)
+static int _tmpexcept(Sfio_t * f, int type, void * val, Sfdisc_t * disc)
{
reg int fd, m;
reg Sfio_t *sf;
/* make sure that the notify function won't be called here since
we are only interested in creating the file, not the stream */
_Sfnotify = 0;
- sf = sfnew(&newf, NIL(Void_t *), (size_t) SF_UNBOUND, fd,
+ sf = sfnew(&newf, NIL(void *), (size_t) SF_UNBOUND, fd,
SF_READ | SF_WRITE);
_Sfnotify = notifyf;
if (!sf)
sfset(sf, (f->mode & (SF_READ | SF_WRITE)), 1);
/* now remake the old stream into the new image */
- memcpy((Void_t *) (&savf), (Void_t *) f, sizeof(Sfio_t));
- memcpy((Void_t *) f, (Void_t *) sf, sizeof(Sfio_t));
+ memcpy((void *) (&savf), (void *) f, sizeof(Sfio_t));
+ memcpy((void *) f, (void *) sf, sizeof(Sfio_t));
f->push = savf.push;
f->pool = savf.pool;
f->rsrv = savf.rsrv;
if (savf.data) {
SFSTRSIZE(&savf);
if (!(savf.flags & SF_MALLOC))
- (void) sfsetbuf(f, (Void_t *) savf.data, savf.size);
+ (void) sfsetbuf(f, (void *) savf.data, savf.size);
if (savf.extent > 0)
- (void) sfwrite(f, (Void_t *) savf.data, (size_t) savf.extent);
+ (void) sfwrite(f, (void *) savf.data, (size_t) savf.extent);
(void) sfseek(f, (Sfoff_t) (savf.next - savf.data), 0);
if ((savf.flags & SF_MALLOC))
- free((Void_t *) savf.data);
+ free((void *) savf.data);
}
/* announce change of status */
f->disc = &Tmpdisc;
/* make the file now */
- if (s == 0 && _tmpexcept(f, SF_DPOP, NIL(Void_t *), f->disc) < 0) {
+ if (s == 0 && _tmpexcept(f, SF_DPOP, NIL(void *), f->disc) < 0) {
sfclose(f);
return NIL(Sfio_t *);
}
**
** Written by Kiem-Phong Vo.
*/
-static int _uexcept(reg Sfio_t * f, reg int type, Void_t * val,
+static int _uexcept(reg Sfio_t * f, reg int type, void * val,
reg Sfdisc_t * disc)
{
NOTUSED(val);
#define SFwrite(f,s,n) \
{ if((endd-d) >= n) { MEMCPY(d,s,n); } \
else \
- { SFEND(f); n_output += (w = SFWRITE(f,(Void_t*)s,n)) > 0 ? w : 0; SFBUF(f); \
+ { SFEND(f); n_output += (w = SFWRITE(f,(void*)s,n)) > 0 ? w : 0; SFBUF(f); \
if(n != w) goto done; \
} \
}
FMTSET(ft, form, args,
LEFTP, 0, 0, 0, 0, 0, NIL(char *), 0);
n = (*ft->extf)
- (f, (Void_t *) & argv, ft);
+ (f, (void *) & argv, ft);
if (n < 0)
goto pop_fmt;
if (!(ft->flags & SFFMT_VALUE))
else if (ft && ft->extf) {
FMTSET(ft, form, args, '.', dot, 0, 0, 0, 0, NIL(char *),
0);
- if ((*ft->extf) (f, (Void_t *) (&argv), ft) < 0)
+ if ((*ft->extf) (f, (void *) (&argv), ft) < 0)
goto pop_fmt;
if (ft->flags & SFFMT_VALUE)
v = argv.i;
else if (ft && ft->extf) {
FMTSET(ft, form, args, 'I', sizeof(int), 0, 0, 0, 0,
NIL(char *), 0);
- if ((*ft->extf) (f, (Void_t *) (&argv), ft) < 0)
+ if ((*ft->extf) (f, (void *) (&argv), ft) < 0)
goto pop_fmt;
if (ft->flags & SFFMT_VALUE)
size = argv.i;
t_str, n_str);
SFEND(f);
SFOPEN(f, 0);
- v = (*ft->extf) (f, (Void_t *) (&argv), ft);
+ v = (*ft->extf) (f, (void *) (&argv), ft);
SFLOCK(f, 0);
SFBUF(f);
argv.d = va_arg(args, double);
break;
case SFFMT_POINTER:
- argv.vp = va_arg(args, Void_t *);
+ argv.vp = va_arg(args, void *);
break;
case SFFMT_BYTE:
if (base >= 0)
goto pop_fmt;
if (!argv.ft->form && ft) { /* change extension functions */
if (ft->eventf &&
- (*ft->eventf) (f, SF_DPOP, (Void_t *) form, ft) < 0)
+ (*ft->eventf) (f, SF_DPOP, (void *) form, ft) < 0)
continue;
fmstk->ft = ft = argv.ft;
} else { /* stack a new environment */
while ((fm = fmstk)) { /* pop the format stack and continue */
if (fm->eventf) {
if (!form || !form[0])
- (*fm->eventf) (f, SF_FINAL, NIL(Void_t *), ft);
- else if ((*fm->eventf) (f, SF_DPOP, (Void_t *) form, ft) < 0)
+ (*fm->eventf) (f, SF_FINAL, NIL(void *), ft);
+ else if ((*fm->eventf) (f, SF_DPOP, (void *) form, ft) < 0)
goto loop_fmt;
}
free(fp);
while ((fm = fmstk)) {
if (fm->eventf)
- (*fm->eventf) (f, SF_FINAL, NIL(Void_t *), fm->ft);
+ (*fm->eventf) (f, SF_FINAL, NIL(void *), fm->ft);
fmstk = fm->next;
free(fm);
}
if ((((flags = f->flags) & SF_SHARE) && !(flags & SF_PUBLIC)) ||
(n > 0 && (d == (uchar *) data || (flags & SF_LINE))))
- (void) SFWRITE(f, (Void_t *) d, n);
+ (void) SFWRITE(f, (void *) d, n);
else
f->next += n;
va_list oargs;
int argp, argn;
- Void_t *value; /* location to assign scanned value */
+ void *value; /* location to assign scanned value */
char *t_str;
ssize_t n_str;
int rs;
#define SFBUF(f) (_sfbuf(f,&rs), (data = d = f->next), (endd = f->endb) )
#define SFLEN(f) (d-data)
#define SFEND(f) ((n_input += d-data), \
- (rs > 0 ? SFREAD(f,(Void_t*)data,d-data) : ((f->next = d), 0)) )
+ (rs > 0 ? SFREAD(f,(void*)data,d-data) : ((f->next = d), 0)) )
#define SFGETC(f,c) ((c) = (d < endd || (SFEND(f), SFBUF(f), d < endd)) ? \
(int)(*d++) : -1 )
#define SFUNGETC(f,c) (--d)
width = dot = 0;
t_str = NIL(char *);
n_str = 0;
- value = NIL(Void_t *);
+ value = NIL(void *);
argp = -1;
loop_flags: /* LOOP FOR FLAGS, WIDTH, BASE, TYPE */
FMTSET(ft, form, args,
LEFTP, 0, 0, 0, 0, 0, NIL(char *), 0);
n = (*ft->extf)
- (f, (Void_t *) & argv, ft);
+ (f, (void *) & argv, ft);
if (n < 0)
goto pop_fmt;
if (!(ft->flags & SFFMT_VALUE))
else if (ft && ft->extf) {
FMTSET(ft, form, args, '.', dot, 0, 0, 0, 0,
NIL(char *), 0);
- if ((*ft->extf) (f, (Void_t *) (&argv), ft) < 0)
+ if ((*ft->extf) (f, (void *) (&argv), ft) < 0)
goto pop_fmt;
if (ft->flags & SFFMT_VALUE)
v = argv.i;
else if (ft && ft->extf) {
FMTSET(ft, form, args, 'I', sizeof(int), 0, 0, 0, 0,
NIL(char *), 0);
- if ((*ft->extf) (f, (Void_t *) (&argv), ft) < 0)
+ if ((*ft->extf) (f, (void *) (&argv), ft) < 0)
goto pop_fmt;
if (ft->flags & SFFMT_VALUE)
size = argv.i;
n_str);
SFEND(f);
SFOPEN(f, 0);
- v = (*ft->extf) (f, (Void_t *) & argv, ft);
+ v = (*ft->extf) (f, (void *) & argv, ft);
SFLOCK(f, 0);
SFBUF(f);
continue;
if (!argv.ft->form && ft) { /* change extension functions */
if (ft->eventf &&
- (*ft->eventf) (f, SF_DPOP, (Void_t *) form, ft) < 0)
+ (*ft->eventf) (f, SF_DPOP, (void *) form, ft) < 0)
continue;
fmstk->ft = ft = argv.ft;
} else { /* stack a new environment */
/* get the address to assign value */
if (!value && !(flags & SFFMT_SKIP))
- value = va_arg(args, Void_t *);
+ value = va_arg(args, void *);
if (fmt == 'n') { /* return length of consumed input */
#if !_ast_intmax_long
if (fmt == 'p')
#if _more_void_int
- *((Void_t **) value) = (Void_t *) ((ulong) argv.lu);
+ *((void **) value) = (void *) ((ulong) argv.lu);
#else
- *((Void_t **) value) = (Void_t *) ((uint) argv.lu);
+ *((void **) value) = (void *) ((uint) argv.lu);
#endif
#if !_ast_intmax_long
else if (FMTCMP(size, Sflong_t, Sflong_t))
while ((fm = fmstk)) { /* pop the format stack and continue */
if (fm->eventf) {
if (!form || !form[0])
- (*fm->eventf) (f, SF_FINAL, NIL(Void_t *), ft);
- else if ((*fm->eventf) (f, SF_DPOP, (Void_t *) form, ft) < 0)
+ (*fm->eventf) (f, SF_FINAL, NIL(void *), ft);
+ else if ((*fm->eventf) (f, SF_DPOP, (void *) form, ft) < 0)
goto loop_fmt;
}
free(fp);
while ((fm = fmstk)) {
if (fm->eventf)
- (*fm->eventf) (f, SF_FINAL, NIL(Void_t *), fm->ft);
+ (*fm->eventf) (f, SF_FINAL, NIL(void *), fm->ft);
fmstk = fm->next;
free(fm);
}
return w > 0 ? w : -1;
}
-ssize_t sfwr(reg Sfio_t * f, reg const Void_t * buf, reg size_t n,
+ssize_t sfwr(reg Sfio_t * f, reg const void * buf, reg size_t n,
reg Sfdisc_t * disc)
{
reg ssize_t w;
* @param buf buffer to be written
* @param n number of bytes
*/
-ssize_t sfwrite(reg Sfio_t * f, const Void_t * buf, reg size_t n)
+ssize_t sfwrite(reg Sfio_t * f, const void * buf, reg size_t n)
{
reg uchar *s, *begs, *next;
reg ssize_t w;
_BEGIN_EXTERNS_ extern Vthread_t *vtopen(Vthread_t *, int);
extern int vtclose(Vthread_t *);
- extern int vtset(Vthread_t *, int, Void_t *);
+ extern int vtset(Vthread_t *, int, void *);
extern int vtrun(Vthread_t *, void *(*)(void *), void *);
extern int vtkill(Vthread_t *);
extern int vtwait(Vthread_t *);
extern int vtmtxunlock(Vtmutex_t *);
extern int vtmtxclrlock(Vtmutex_t *);
- extern Void_t *vtstatus(Vthread_t *);
+ extern void *vtstatus(Vthread_t *);
extern int vterror(Vthread_t *);
extern int vtmtxerror(Vtmutex_t *);
extern int vtonceerror(Vtonce_t *);
size_t stack; /* stack size */
int state; /* execution state */
int error; /* error status */
- Void_t *exit; /* exit value */
+ void *exit; /* exit value */
};
/* structure for exactly once execution */
#define vtmtxunlock(mtx) (void)(-1)
#define vtmtxclrlock(mtx) (void)(-1)
-#define vtstatus(vt) ((Void_t*)0)
+#define vtstatus(vt) ((void*)0)
#define vterror(vt) (0)
#define vtmtxerror(mtx) (0)
#define vtonceerror(once) (0)
#define __INLINE__ __inline
#endif
- /* Void_t is defined so that Void_t* can address any type */
- #ifndef Void_t
- #define Void_t void
- #endif /*Void_t*/
-
/* dynamic linked library external scope handling */
#undef extern
#if _dll_import && !defined(__EXPORT__) && _DLL_BLD
env += 1;
else if (env[0] == '0' && (env[1] == 'x' || env[1] == 'X')) {
if ((addr = atou(&env)) != 0)
- vmdbwatch((Void_t *) addr);
+ vmdbwatch((void *) addr);
} else {
_Vmdbcheck = atou(&env);
setcheck = 1;
return 0;
}
-Void_t *malloc(reg size_t size)
+void *malloc(reg size_t size)
{
VMFLINIT();
return (*Vmregion->meth.allocf) (Vmregion, size);
* @param data block to be reallocated
* @param size new size
*/
-Void_t *realloc(reg Void_t * data, reg size_t size)
+void *realloc(reg void * data, reg size_t size)
{
VMFLINIT();
return (*Vmregion->meth.resizef) (Vmregion, data, size,
VM_RSCOPY | VM_RSMOVE);
}
-void free(reg Void_t * data)
+void free(reg void * data)
{
VMFLINIT();
(void) (*Vmregion->meth.freef) (Vmregion, data);
}
-Void_t *calloc(reg size_t n_obj, reg size_t s_obj)
+void *calloc(reg size_t n_obj, reg size_t s_obj)
{
VMFLINIT();
- return (*Vmregion->meth.resizef) (Vmregion, NIL(Void_t *),
+ return (*Vmregion->meth.resizef) (Vmregion, NIL(void *),
n_obj * s_obj, VM_RSZERO);
}
-void cfree(reg Void_t * data)
+void cfree(reg void * data)
{
VMFLINIT();
(void) (*Vmregion->meth.freef) (Vmregion, data);
}
-Void_t *memalign(reg size_t align, reg size_t size)
+void *memalign(reg size_t align, reg size_t size)
{
VMFLINIT();
return (*Vmregion->meth.alignf) (Vmregion, size, align);
}
-Void_t *valloc(reg size_t size)
+void *valloc(reg size_t size)
{
VMFLINIT();
GETPAGESIZE(_Vmpagesize);
Vmuchar_t data[1];
};
-Void_t *alloca(size_t size)
+void *alloca(size_t size)
{
char array[ALIGN];
char *file;
f->head.head.next = Frame;
Frame = f;
- return (Void_t *) f->data;
+ return (void *) f->data;
}
#endif /*!_lib_alloca || _mal_alloca */
typedef struct _vmstat_s Vmstat_t;
typedef struct _vmdisc_s Vmdisc_t;
typedef struct _vmethod_s Vmethod_t;
- typedef Void_t *(*Vmemory_f)
- (Vmalloc_t *, Void_t *, size_t, size_t, Vmdisc_t *);
+ typedef void *(*Vmemory_f)
+ (Vmalloc_t *, void *, size_t, size_t, Vmdisc_t *);
typedef int (*Vmexcept_f)
- (Vmalloc_t *, int, Void_t *, Vmdisc_t *);
+ (Vmalloc_t *, int, void *, Vmdisc_t *);
struct _vmstat_s {
int n_busy; /* number of busy blocks */
};
struct _vmethod_s {
- Void_t *(*allocf) (Vmalloc_t *, size_t);
- Void_t *(*resizef) (Vmalloc_t *, Void_t *, size_t, int);
- int (*freef) (Vmalloc_t *, Void_t *);
- long (*addrf) (Vmalloc_t *, Void_t *);
- long (*sizef) (Vmalloc_t *, Void_t *);
+ void *(*allocf) (Vmalloc_t *, size_t);
+ void *(*resizef) (Vmalloc_t *, void *, size_t, int);
+ int (*freef) (Vmalloc_t *, void *);
+ long (*addrf) (Vmalloc_t *, void *);
+ long (*sizef) (Vmalloc_t *, void *);
int (*compactf) (Vmalloc_t *);
- Void_t *(*alignf) (Vmalloc_t *, size_t, size_t);
+ void *(*alignf) (Vmalloc_t *, size_t, size_t);
unsigned short meth;
};
extern Vmdisc_t *vmdisc(Vmalloc_t *, Vmdisc_t *);
- extern Void_t *vmalloc(Vmalloc_t *, size_t);
- extern Void_t *vmalign(Vmalloc_t *, size_t, size_t);
- extern Void_t *vmresize(Vmalloc_t *, Void_t *, size_t, int);
- extern int vmfree(Vmalloc_t *, Void_t *);
+ extern void *vmalloc(Vmalloc_t *, size_t);
+ extern void *vmalign(Vmalloc_t *, size_t, size_t);
+ extern void *vmresize(Vmalloc_t *, void *, size_t, int);
+ extern int vmfree(Vmalloc_t *, void *);
- extern long vmaddr(Vmalloc_t *, Void_t *);
- extern long vmsize(Vmalloc_t *, Void_t *);
+ extern long vmaddr(Vmalloc_t *, void *);
+ extern long vmsize(Vmalloc_t *, void *);
- extern Vmalloc_t *vmregion(Void_t *);
- extern Void_t *vmsegment(Vmalloc_t *, Void_t *);
+ extern Vmalloc_t *vmregion(void *);
+ extern void *vmsegment(Vmalloc_t *, void *);
extern int vmset(Vmalloc_t *, int, int);
- extern Void_t *vmdbwatch(Void_t *);
+ extern void *vmdbwatch(void *);
extern int vmdbcheck(Vmalloc_t *);
extern int vmprofile(Vmalloc_t *, int);
extern int vmstat(Vmalloc_t *, Vmstat_t *);
extern int vmwalk(Vmalloc_t *,
- int (*)(Vmalloc_t *, Void_t *, size_t,
+ int (*)(Vmalloc_t *, void *, size_t,
Vmdisc_t *));
extern char *vmstrdup(Vmalloc_t *, const char *);
(*(_VM_(vm)->meth.allocf))((vm),(sz)) )
#define vmresize(vm,d,sz,type) (_VMFL_(vm), \
(*(_VM_(vm)->meth.resizef))\
- ((vm),(Void_t*)(d),(sz),(type)) )
+ ((vm),(void*)(d),(sz),(type)) )
#define vmfree(vm,d) (_VMFL_(vm), \
- (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d)) )
+ (*(_VM_(vm)->meth.freef))((vm),(void*)(d)) )
#define vmalign(vm,sz,align) (_VMFL_(vm), \
(*(_VM_(vm)->meth.alignf))((vm),(sz),(align)) )
#define malloc(s) (_VMFL_(Vmregion), malloc((size_t)(s)) )
-#define realloc(d,s) (_VMFL_(Vmregion), realloc((Void_t*)(d),(size_t)(s)) )
+#define realloc(d,s) (_VMFL_(Vmregion), realloc((void*)(d),(size_t)(s)) )
#define calloc(n,s) (_VMFL_(Vmregion), calloc((size_t)n, (size_t)(s)) )
-#define free(d) (_VMFL_(Vmregion), free((Void_t*)(d)) )
+#define free(d) (_VMFL_(Vmregion), free((void*)(d)) )
#define memalign(a,s) (_VMFL_(Vmregion), memalign((size_t)(a),(size_t)(s)) )
#define valloc(s) (_VMFL_(Vmregion), valloc((size_t)(s) )
#define cfree(d) free(d)
#endif
#ifndef vmresize
#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\
- ((vm),(Void_t*)(d),(sz),(type))
+ ((vm),(void*)(d),(sz),(type))
#endif
#ifndef vmfree
-#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d))
+#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(void*)(d))
#endif
#ifndef vmalign
#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align))
#endif
-#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr))
-#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr))
+#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(void*)(addr))
+#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(void*)(addr))
#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm))
#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
(VM_RSMOVE) )
* @param vm region allocating from
* @param size desired block size
*/
-static Void_t *bestalloc(Vmalloc_t * vm, reg size_t size)
+static void *bestalloc(Vmalloc_t * vm, reg size_t size)
{
reg Vmdata_t *vd = vm->data;
reg size_t s;
if (!(local = vd->mode & VM_TRUST)) {
GETLOCAL(vd, local);
if (ISLOCK(vd, local))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, local);
orgsize = size;
}
vd->mode &= ~VM_AGAIN;
else {
CLRLOCK(vd, local);
- return NIL(Void_t *);
+ return NIL(void *);
}
}
* @param vm region allocating from
* @param addr address to check
*/
-static long bestaddr(Vmalloc_t * vm, Void_t * addr)
+static long bestaddr(Vmalloc_t * vm, void * addr)
{
reg Seg_t *seg;
reg Block_t *b, *endb;
return offset;
}
-static int bestfree(Vmalloc_t * vm, Void_t * data)
+static int bestfree(Vmalloc_t * vm, void * data)
{
reg Vmdata_t *vd = vm->data;
reg Block_t *bp, **cache;
* @param size new size
* @param type !=0 to move, <0 for not copy
*/
-static Void_t *bestresize(Vmalloc_t * vm, Void_t * data, reg size_t size,
+static void *bestresize(Vmalloc_t * vm, void * data, reg size_t size,
int type)
{
reg Vmdata_t *vd = vm->data;
reg size_t s, bs;
reg int local, *d, *ed;
size_t oldsize = 0, orgsize = 0;
- Void_t *orgdata;
+ void *orgdata;
orgdata = 0;
/**/ COUNT(N_resize);
}
if (size == 0) {
(void) bestfree(vm, data);
- return NIL(Void_t *);
+ return NIL(void *);
}
if (!(local = vd->mode & VM_TRUST)) {
GETLOCAL(vd, local);
if (ISLOCK(vd, local))
- return NIL(Void_t *);
+ return NIL(void *);
if (!local && KPVADDR(vm, data, bestaddr) != 0)
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, local);
orgdata = data; /* for tracing */
goto do_free;
} else if (s < size) {
if (!(type & (VM_RSMOVE | VM_RSCOPY))) /* see if old data is moveable */
- data = NIL(Void_t *);
+ data = NIL(void *);
else {
ed = (int *) data;
if (size < ((s & ~BITS) + bs))
* @param vm region allocating from
* @param addr address to check
*/
-static long bestsize(Vmalloc_t * vm, Void_t * addr)
+static long bestsize(Vmalloc_t * vm, void * addr)
{
reg Seg_t *seg;
reg Block_t *b, *endb;
return 0;
}
-static Void_t *bestalign(Vmalloc_t * vm, size_t size, size_t align)
+static void *bestalign(Vmalloc_t * vm, size_t size, size_t align)
{
reg Vmuchar_t *data;
reg Block_t *tp, *np;
reg Vmdata_t *vd = vm->data;
if (size <= 0 || align <= 0)
- return NIL(Void_t *);
+ return NIL(void *);
if (!(local = vd->mode & VM_TRUST)) {
GETLOCAL(vd, local);
if (ISLOCK(vd, local))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, local);
orgsize = size;
orgalign = align;
/**/ ASSERT(!vd->root || vmchktree(vd->root));
- return (Void_t *) data;
+ return (void *) data;
}
/* A discipline to get memory using sbrk() or VirtualAlloc on win32 */
* @param nsize new size
* @param disc discipline structure
*/
-static Void_t *sbrkmem(Vmalloc_t * vm, Void_t * caddr,
+static void *sbrkmem(Vmalloc_t * vm, void * caddr,
size_t csize, size_t nsize, Vmdisc_t * disc)
{
#if _std_malloc || _BLD_INSTRUMENT || cray
NOTUSED(disc);
if (csize == 0)
- return (Void_t *) malloc(nsize);
+ return (void *) malloc(nsize);
if (nsize == 0)
free(caddr);
- return NIL(Void_t *);
+ return NIL(void *);
#else
#if defined(_WIN32)
NOTUSED(vm);
NOTUSED(disc);
if (csize == 0)
- return (Void_t *) VirtualAlloc(NIL(LPVOID), nsize, MEM_COMMIT,
+ return (void *) VirtualAlloc(NIL(LPVOID), nsize, MEM_COMMIT,
PAGE_READWRITE);
else if (nsize == 0)
return VirtualFree((LPVOID) caddr, 0,
- MEM_RELEASE) ? caddr : NIL(Void_t *);
+ MEM_RELEASE) ? caddr : NIL(void *);
else
- return NIL(Void_t *);
+ return NIL(void *);
#else
reg Vmuchar_t *addr;
reg ssize_t size;
/* sbrk, see if still own current address */
if (csize > 0 && sbrk(0) != (Vmuchar_t *) caddr + csize)
- return NIL(Void_t *);
+ return NIL(void *);
/* do this because sbrk() uses 'ssize_t' argument */
size =
csize ? (ssize_t) (nsize - csize) : -(ssize_t) (csize - nsize);
if ((addr = sbrk(size)) == (Vmuchar_t *) (-1))
- return NIL(Void_t *);
+ return NIL(void *);
else
- return csize == 0 ? (Void_t *) addr : caddr;
+ return csize == 0 ? (void *) addr : caddr;
#endif
#endif
}
return -1;
if (vm->disc->exceptf &&
- (*vm->disc->exceptf) (vm, VM_CLOSE, NIL(Void_t *), vm->disc) < 0)
+ (*vm->disc->exceptf) (vm, VM_CLOSE, NIL(void *), vm->disc) < 0)
return -1;
/* make this region inaccessible until it disappears */
* @param nsize new size
* @param disc discipline structure
*/
-static Void_t *heapmem(Vmalloc_t * vm, Void_t * caddr,
+static void *heapmem(Vmalloc_t * vm, void * caddr,
size_t csize, size_t nsize, Vmdisc_t * disc)
{
NOTUSED(vm);
if (csize == 0)
return vmalloc(Vmheap, nsize);
else if (nsize == 0)
- return vmfree(Vmheap, caddr) >= 0 ? caddr : NIL(Void_t *);
+ return vmfree(Vmheap, caddr) >= 0 ? caddr : NIL(void *);
else
return vmresize(Vmheap, caddr, nsize, 0);
}
/* global watch list */
#define S_WATCH 32
static int Dbnwatch;
-static Void_t *Dbwatch[S_WATCH];
+static void *Dbwatch[S_WATCH];
/* types of warnings reported by dbwarn() */
#define DB_CHECK 0
* @param line line number of call
* @param type operation being done
*/
-static void dbwarn(Vmalloc_t * vm, Void_t * data, int where, char *file,
+static void dbwarn(Vmalloc_t * vm, void * data, int where, char *file,
int line, int type)
{
char buf[1024], *bufp, *endbuf, *s;
}
/* check for watched address and issue warnings */
-static void dbwatch(Vmalloc_t * vm, Void_t * data, char *file, int line,
+static void dbwatch(Vmalloc_t * vm, void * data, char *file, int line,
int type)
{
reg int n;
** This returns -(offset+1) if block is already freed, +(offset+1)
** if block is live, 0 if no match.
*/
-static long dbaddr(Vmalloc_t * vm, Void_t * addr)
+static long dbaddr(Vmalloc_t * vm, void * addr)
{
reg Block_t *b = NULL, *endb = NULL;
reg Seg_t *seg;
}
-static long dbsize(Vmalloc_t * vm, Void_t * addr)
+static long dbsize(Vmalloc_t * vm, void * addr)
{
reg Block_t *b, *endb;
reg Seg_t *seg;
(Vmuchar_t *) addr >= (Vmuchar_t *) endb)
continue;
while (b < endb) {
- if (addr == (Void_t *) DB2DEBUG(DATA(b))) {
+ if (addr == (void *) DB2DEBUG(DATA(b))) {
if (ISBUSY(SIZE(b)) && !ISJUNK(SIZE(b)))
size = (long) DBSIZE(addr);
goto done;
return size;
}
-static Void_t *dballoc(Vmalloc_t * vm, size_t size)
+static void *dballoc(Vmalloc_t * vm, size_t size)
{
reg size_t s;
reg Vmuchar_t *data;
if (ISLOCK(vd, 0)) {
dbwarn(vm, NIL(Vmuchar_t *), 0, file, line, DB_ALLOC);
- return NIL(Void_t *);
+ return NIL(void *);
}
SETLOCK(vd, 0);
done:
CLRLOCK(vd, 0);
- return (Void_t *) data;
+ return (void *) data;
}
-static int dbfree(Vmalloc_t * vm, Void_t * data)
+static int dbfree(Vmalloc_t * vm, void * data)
{
char *file;
int line;
*ip++ = 0;
CLRLOCK(vd, 0);
- return (*(Vmbest->freef)) (vm, (Void_t *) DB2BEST(data));
+ return (*(Vmbest->freef)) (vm, (void *) DB2BEST(data));
}
/* Resizing an existing block */
* @param size new size
* @param type !=0 for movable, >0 for copy
*/
-static Void_t *dbresize(Vmalloc_t * vm, Void_t * addr, reg size_t size,
+static void *dbresize(Vmalloc_t * vm, void * addr, reg size_t size,
int type)
{
reg Vmuchar_t *data;
}
if (size == 0) {
(void) dbfree(vm, addr);
- return NIL(Void_t *);
+ return NIL(void *);
}
VMFILELINE(vm, file, line);
if (ISLOCK(vd, 0)) {
dbwarn(vm, NIL(Vmuchar_t *), 0, file, line, DB_RESIZE);
- return NIL(Void_t *);
+ return NIL(void *);
}
SETLOCK(vd, 0);
dbwarn(vm, (Vmuchar_t *) addr, offset == -1L ? 0 : 1, file, line,
DB_RESIZE);
CLRLOCK(vd, 0);
- return NIL(Void_t *);
+ return NIL(void *);
}
if (Dbnwatch > 0)
s = ROUND(size, ALIGN) + DB_EXTRA;
if (s < sizeof(Body_t))
s = sizeof(Body_t);
- data = (Vmuchar_t *) KPVRESIZE(vm, (Void_t *) data, s,
+ data = (Vmuchar_t *) KPVRESIZE(vm, (void *) data, s,
(type & ~VM_RSZERO),
(*(Vmbest->resizef)));
if (!data) { /* failed, reset data for old block */
*d++ = 0;
} while (d < ed);
}
- return (Void_t *) data;
+ return (void *) data;
}
/* compact any residual free space */
*
* @param addr address to insert
*/
-Void_t *vmdbwatch(Void_t * addr)
+void *vmdbwatch(void * addr)
{
reg int n;
- reg Void_t *out;
+ reg void *out;
- out = NIL(Void_t *);
+ out = NIL(void *);
if (!addr)
Dbnwatch = 0;
else {
return out;
}
-static Void_t *dbalign(Vmalloc_t * vm, size_t size, size_t align)
+static void *dbalign(Vmalloc_t * vm, size_t size, size_t align)
{
reg Vmuchar_t *data;
reg size_t s;
VMFILELINE(vm, file, line);
if (size <= 0 || align <= 0)
- return NIL(Void_t *);
+ return NIL(void *);
if (!(vd->mode & VM_TRUST)) {
if (ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
}
done:
CLRLOCK(vd, 0);
- return (Void_t *) data;
+ return (void *) data;
}
static Vmethod_t _Vmdebug = {
if (disc->memoryf != old->memoryf)
return NIL(Vmdisc_t *);
if (old->exceptf &&
- (*old->exceptf) (vm, VM_DISC, (Void_t *) disc, old) != 0)
+ (*old->exceptf) (vm, VM_DISC, (void *) disc, old) != 0)
return NIL(Vmdisc_t *);
vm->disc = disc;
}
struct _seg_s {
Vmalloc_t *vm; /* the region that holds this */
Seg_t *next; /* next segment */
- Void_t *addr; /* starting segment address */
+ void *addr; /* starting segment address */
size_t extent; /* extent of segment */
Vmuchar_t *baddr; /* bottom of usable memory */
size_t size; /* allocable size */
#define RIGHT(b) ((b)->body.body.right)
#define VM(b) (SEG(b)->vm)
-#define DATA(b) ((Void_t*)((b)->body.data) )
+#define DATA(b) ((void*)((b)->body.data) )
#define BLOCK(d) ((Block_t*)((char*)(d) - sizeof(Head_t)) )
#define SELF(b) ((Block_t**)((b)->body.data + SIZE(b) - sizeof(Block_t*)) )
#define LAST(b) (*((Block_t**)(((char*)(b)) - sizeof(Block_t*)) ) )
/* clear and copy functions */
#define INTCOPY(to,fr,n) \
switch(n/sizeof(int)) \
- { default: memcpy((Void_t*)to,(Void_t*)fr,n); break; \
+ { default: memcpy((void*)to,(void*)fr,n); break; \
case 7: *to++ = *fr++; \
case 6: *to++ = *fr++; \
case 5: *to++ = *fr++; \
}
#define INTZERO(d,n) \
switch(n/sizeof(int)) \
- { default: memset((Void_t*)d,0,n); break; \
+ { default: memset((void*)d,0,n); break; \
case 7: *d++ = 0; \
case 6: *d++ = 0; \
case 5: *d++ = 0; \
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-static Void_t *lastalloc(Vmalloc_t * vm, size_t size)
+static void *lastalloc(Vmalloc_t * vm, size_t size)
{
reg Block_t *tp, *next;
reg Seg_t *seg, *last;
if (!(local = vd->mode & VM_TRUST)) {
GETLOCAL(vd, local);
if (ISLOCK(vd, local))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, local);
orgsize = size;
}
done:
CLRLOCK(vd, local);
- return (Void_t *) tp;
+ return (void *) tp;
}
-static int lastfree(Vmalloc_t * vm, reg Void_t * data)
+static int lastfree(Vmalloc_t * vm, reg void * data)
{
reg Seg_t *seg;
reg Block_t *fp;
return -1;
SETLOCK(vd, 0);
}
- if (data != (Void_t *) vd->free) {
+ if (data != (void *) vd->free) {
if (!local && vm->disc->exceptf)
(void) (*vm->disc->exceptf) (vm, VM_BADADDR, data, vm->disc);
CLRLOCK(vd, 0);
return 0;
}
-static Void_t *lastresize(Vmalloc_t * vm, reg Void_t * data, size_t size,
+static void *lastresize(Vmalloc_t * vm, reg void * data, size_t size,
int type)
{
reg Block_t *tp;
reg ssize_t s, ds;
reg Vmdata_t *vd = vm->data;
reg int local;
- reg Void_t *addr;
- Void_t *orgdata = 0;
+ reg void *addr;
+ void *orgdata = 0;
size_t orgsize = 0;
if (!data) {
}
if (size <= 0) {
(void) lastfree(vm, data);
- return NIL(Void_t *);
+ return NIL(void *);
}
if (!(local = vd->mode & VM_TRUST)) {
if (ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
orgdata = data;
orgsize = size;
}
- if (data == (Void_t *) vd->free)
+ if (data == (void *) vd->free)
seg = vd->seg;
else { /* see if it was one of ours */
for (seg = vd->seg; seg; seg = seg->next)
- if (data >= seg->addr && data < (Void_t *) seg->baddr)
+ if (data >= seg->addr && data < (void *) seg->baddr)
break;
if (!seg || (VLONG(data) % ALIGN) != 0 ||
(seg->last && (Vmuchar_t *) data > (Vmuchar_t *) seg->last)) {
CLRLOCK(vd, 0);
- return NIL(Void_t *);
+ return NIL(void *);
}
}
} else {
do_alloc:
if (!(type & (VM_RSMOVE | VM_RSCOPY)))
- data = NIL(Void_t *);
+ data = NIL(void *);
else {
tp = vd->free;
if (!(addr = KPVALLOC(vm, size, lastalloc))) {
vd->free = tp;
- data = NIL(Void_t *);
+ data = NIL(void *);
} else {
if (type & VM_RSCOPY) {
ed = (int *) data;
}
-static long lastaddr(Vmalloc_t * vm, Void_t * addr)
+static long lastaddr(Vmalloc_t * vm, void * addr)
{
reg Vmdata_t *vd = vm->data;
if (!(vd->mode & VM_TRUST) && ISLOCK(vd, 0))
return -1L;
- if (!vd->free || addr < (Void_t *) vd->free
- || addr >= (Void_t *) vd->seg->baddr)
+ if (!vd->free || addr < (void *) vd->free
+ || addr >= (void *) vd->seg->baddr)
return -1L;
else
return (Vmuchar_t *) addr - (Vmuchar_t *) vd->free;
}
-static long lastsize(Vmalloc_t * vm, Void_t * addr)
+static long lastsize(Vmalloc_t * vm, void * addr)
{
reg Vmdata_t *vd = vm->data;
if (!(vd->mode & VM_TRUST) && ISLOCK(vd, 0))
return -1L;
- if (!vd->free || addr != (Void_t *) vd->free)
+ if (!vd->free || addr != (void *) vd->free)
return -1L;
else if (vd->seg->free)
return (Vmuchar_t *) vd->seg->free - (Vmuchar_t *) addr;
return 0;
}
-static Void_t *lastalign(Vmalloc_t * vm, size_t size, size_t align)
+static void *lastalign(Vmalloc_t * vm, size_t size, size_t align)
{
reg Vmuchar_t *data;
reg size_t s, orgsize = 0, orgalign = 0;
reg Vmdata_t *vd = vm->data;
if (size <= 0 || align <= 0)
- return NIL(Void_t *);
+ return NIL(void *);
if (!(local = vd->mode & VM_TRUST)) {
GETLOCAL(vd, local);
if (ISLOCK(vd, local))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, local);
orgsize = size;
orgalign = align;
done:
CLRLOCK(vd, local);
- return (Void_t *) data;
+ return (void *) data;
}
/* Public method for free-1 allocation */
if (disc->exceptf) {
addr = NIL(Vmuchar_t *);
if ((e =
- (*disc->exceptf) (vm, VM_OPEN, (Void_t *) (&addr),
+ (*disc->exceptf) (vm, VM_OPEN, (void *) (&addr),
disc)) != 0) {
if (e < 0 || !addr)
goto open_error;
/* get space for region data */
s = ROUND(sizeof(Vminit_t), incr);
- if (!(addr = (Vmuchar_t *) (*memoryf) (vm, NIL(Void_t *), 0, s, disc))) {
+ if (!(addr = (Vmuchar_t *) (*memoryf) (vm, NIL(void *), 0, s, disc))) {
vmfree(Vmheap, vm);
return NIL(Vmalloc_t *);
}
seg = vd->seg;
seg->next = NIL(Seg_t *);
seg->vm = vm;
- seg->addr = (Void_t *) (addr - (a ? ALIGN - a : 0));
+ seg->addr = (void *) (addr - (a ? ALIGN - a : 0));
seg->extent = s;
seg->baddr = addr + s - (a ? ALIGN : 0);
seg->size = s; /* this size is larger than usual so that the segment
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-static Void_t *poolalloc(Vmalloc_t * vm, reg size_t size)
+static void *poolalloc(Vmalloc_t * vm, reg size_t size)
{
reg Vmdata_t *vd = vm->data;
reg Block_t *tp, *next;
reg int local;
if (size <= 0)
- return NIL(Void_t *);
+ return NIL(void *);
else if (size != vd->pool) {
if (vd->pool <= 0)
vd->pool = size;
else
- return NIL(Void_t *);
+ return NIL(void *);
}
if (!(local = vd->mode & VM_TRUST)) {
if (ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
}
(*_Vmtrace) (vm, NIL(Vmuchar_t *), (Vmuchar_t *) tp, vd->pool, 0);
CLRLOCK(vd, 0);
- return (Void_t *) tp;
+ return (void *) tp;
}
-static long pooladdr(Vmalloc_t * vm, reg Void_t * addr)
+static long pooladdr(Vmalloc_t * vm, reg void * addr)
{
reg Block_t *bp, *tp;
reg Vmuchar_t *laddr, *baddr;
return offset;
}
-static int poolfree(reg Vmalloc_t * vm, reg Void_t * data)
+static int poolfree(reg Vmalloc_t * vm, reg void * data)
{
reg Block_t *bp;
reg Vmdata_t *vd = vm->data;
return 0;
}
-static Void_t *poolresize(Vmalloc_t * vm, Void_t * data, size_t size,
+static void *poolresize(Vmalloc_t * vm, void * data, size_t size,
int type)
{
reg Vmdata_t *vd = vm->data;
}
if (size == 0) {
(void) poolfree(vm, data);
- return NIL(Void_t *);
+ return NIL(void *);
}
if (!(vd->mode & VM_TRUST)) {
if (ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
if (size != vd->pool || KPVADDR(vm, data, pooladdr) != 0) {
if (vm->disc->exceptf)
(void) (*vm->disc->exceptf) (vm, VM_BADADDR, data,
vm->disc);
- return NIL(Void_t *);
+ return NIL(void *);
}
if ((vd->mode & VM_TRACE) && _Vmtrace)
return data;
}
-static long poolsize(Vmalloc_t * vm, Void_t * addr)
+static long poolsize(Vmalloc_t * vm, void * addr)
{
return pooladdr(vm, addr) == 0 ? (long) vm->data->pool : -1L;
}
return 0;
}
-static Void_t *poolalign(Vmalloc_t * vm, size_t size, size_t align)
+static void *poolalign(Vmalloc_t * vm, size_t size, size_t align)
{
NOTUSED(vm);
NOTUSED(size);
NOTUSED(align);
- return NIL(Void_t *);
+ return NIL(void *);
}
/* Public interface */
while (!addr) { /* try to get space */
if ((addr =
- (Vmuchar_t *) (*memoryf) (vm, NIL(Void_t *), 0, size,
+ (Vmuchar_t *) (*memoryf) (vm, NIL(void *), 0, size,
vm->disc)))
break;
int rv, lock;
lock = vd->mode & VM_LOCK;
vd->mode &= ~VM_LOCK;
- rv = (*exceptf) (vm, VM_NOMEM, (Void_t *) size, vm->disc);
+ rv = (*exceptf) (vm, VM_NOMEM, (void *) size, vm->disc);
vd->mode |= lock;
if (rv <= 0) {
if (rv == 0)
seg = (Seg_t *) addr;
seg->vm = vm;
- seg->addr = (Void_t *) (addr - (s ? ALIGN - s : 0));
+ seg->addr = (void *) (addr - (s ? ALIGN - s : 0));
seg->extent = size;
seg->baddr = addr + size - (s ? 2 * ALIGN : 0);
seg->free = NIL(Block_t *);
*/
static int vmtruncate(Vmalloc_t * vm, Seg_t * seg, size_t size, int exact)
{
- reg Void_t *caddr;
+ reg void *caddr;
reg Seg_t *last;
reg Vmdata_t *vd = vm->data;
reg Vmemory_f memoryf = vm->disc->memoryf;
return 0;
}
-static Void_t *pfalloc(Vmalloc_t * vm, size_t size)
+static void *pfalloc(Vmalloc_t * vm, size_t size)
{
reg size_t s;
- reg Void_t *data;
+ reg void *data;
reg char *file;
reg int line;
reg Vmdata_t *vd = vm->data;
VMFILELINE(vm, file, line);
if (!(vd->mode & VM_TRUST) && ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
s = ROUND(size, ALIGN) + PF_EXTRA;
return data;
}
-static int pffree(Vmalloc_t * vm, Void_t * data)
+static int pffree(Vmalloc_t * vm, void * data)
{
reg Pfobj_t *pf;
reg size_t s;
return (*(Vmbest->freef)) (vm, data);
}
-static Void_t *pfresize(Vmalloc_t * vm, Void_t * data, size_t size,
+static void *pfresize(Vmalloc_t * vm, void * data, size_t size,
int type)
{
reg Pfobj_t *pf;
reg size_t s, news;
- reg Void_t *addr;
+ reg void *addr;
reg char *file;
reg int line;
reg size_t oldsize;
}
if (size == 0) {
(void) pffree(vm, data);
- return NIL(Void_t *);
+ return NIL(void *);
}
VMFILELINE(vm, file, line);
if (!(vd->mode & VM_TRUST)) {
if (ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
}
if (vm->disc->exceptf)
(void) (*vm->disc->exceptf) (vm, VM_BADADDR, data, vm->disc);
CLRLOCK(vd, 0);
- return NIL(Void_t *);
+ return NIL(void *);
}
pf = PFOBJ(data);
return addr;
}
-static long pfsize(Vmalloc_t * vm, Void_t * addr)
+static long pfsize(Vmalloc_t * vm, void * addr)
{
return (*Vmbest->addrf) (vm, addr) != 0 ? -1L : (long) PFSIZE(addr);
}
-static long pfaddr(Vmalloc_t * vm, Void_t * addr)
+static long pfaddr(Vmalloc_t * vm, void * addr)
{
return (*Vmbest->addrf) (vm, addr);
}
return (*Vmbest->compactf) (vm);
}
-static Void_t *pfalign(Vmalloc_t * vm, size_t size, size_t align)
+static void *pfalign(Vmalloc_t * vm, size_t size, size_t align)
{
reg size_t s;
- reg Void_t *data;
+ reg void *data;
reg char *file;
reg int line;
reg Vmdata_t *vd = vm->data;
VMFILELINE(vm, file, line);
if (!(vd->mode & VM_TRUST) && ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
s = (size <= TINYSIZE ? TINYSIZE : ROUND(size, ALIGN)) + PF_EXTRA;
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-Vmalloc_t *vmregion(reg Void_t * addr)
+Vmalloc_t *vmregion(reg void * addr)
{
return addr ? VM(BLOCK(addr)) : NIL(Vmalloc_t *);
}
* @param vm region
* @param addr address
*/
-Void_t *vmsegment(Vmalloc_t * vm, Void_t * addr)
+void *vmsegment(Vmalloc_t * vm, void * addr)
{
reg Seg_t *seg;
reg Vmdata_t *vd = vm->data;
if (!(vd->mode & VM_TRUST)) {
if (ISLOCK(vd, 0))
- return NIL(Void_t *);
+ return NIL(void *);
SETLOCK(vd, 0);
}
break;
CLRLOCK(vd, 0);
- return seg ? (Void_t *) seg->addr : NIL(Void_t *);
+ return seg ? (void *) seg->addr : NIL(void *);
}
*/
int vmwalk(Vmalloc_t * vm,
- int (*segf) (Vmalloc_t *, Void_t *, size_t, Vmdisc_t *))
+ int (*segf) (Vmalloc_t *, void *, size_t, Vmdisc_t *))
{
reg Seg_t *seg;
reg int rv;
#define __INLINE__ __inline
#endif
-/* Void_t is defined so that Void_t* can address any type */
-#ifndef Void_t
-#define Void_t void
-#endif /*Void_t */
-
/* dynamic linked library external scope handling */
#undef extern
#if defined(_dll_import) && !defined(__EXPORT__) && defined(_DLL_BLD)