Changeset: bae3132affe6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bae3132affe6
Modified Files:
        clients/Tests/exports.stable.out
        geom/monetdb5/geom.c
        geom/monetdb5/geom.h
        monetdb5/mal/mal_prelude.c
        monetdb5/mal/mel.h
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/atoms/blob.h
        monetdb5/modules/atoms/color.c
        monetdb5/modules/atoms/color.h
        monetdb5/modules/atoms/identifier.c
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/atoms/json.h
        monetdb5/modules/atoms/url.c
        monetdb5/modules/atoms/url.h
        monetdb5/modules/atoms/uuid.c
        monetdb5/modules/atoms/xml.c
        monetdb5/modules/atoms/xml.h
Branch: default
Log Message:

Reduce casting of function pointers, reduce exports.


diffs (truncated from 1454 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -948,22 +948,12 @@ str BKCsetTransient(void *r, const bat *
 str BKCshrinkBAT(bat *ret, const bat *bid, const bat *did);
 str BLOBblob_blob(blob **d, blob **s);
 str BLOBblob_fromstr(blob **b, const char **d);
-int BLOBcmp(const blob *l, const blob *r);
-void BLOBdel(Heap *h, var_t *index);
-ssize_t BLOBfromstr(const char *instr, size_t *l, blob **val, bool external);
 int BLOBget(Heap *h, int *bun, int *l, blob **val);
-BUN BLOBhash(const blob *b);
-void BLOBheap(Heap *heap, size_t capacity);
-size_t BLOBlength(const blob *p);
 str BLOBnitems(int *ret, blob **b);
 str BLOBnitems_bulk(bat *ret, const bat *bid);
-const blob *BLOBnull(void);
 str BLOBprelude(void *ret);
-var_t BLOBput(Heap *h, var_t *bun, const blob *val);
-blob *BLOBread(blob *a, stream *s, size_t cnt);
 str BLOBtoblob(blob **retval, str *s);
-ssize_t BLOBtostr(str *tostr, size_t *l, const blob *pin, bool external);
-gdk_return BLOBwrite(const blob *a, stream *s, size_t cnt);
+ssize_t BLOBtostr(str *tostr, size_t *l, const void *pin, bool external);
 str CALCmax(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 str CALCmax_no_nil(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 str CALCmin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
@@ -1312,9 +1302,7 @@ str GRPsubgroup7(bat *ngid, bat *next, c
 str GRPsubgroup8(bat *ngid, bat *next, const bat *bid, const bat *gid, const 
bat *eid, const bat *hid);
 str GRPsubgroup9(bat *ngid, bat *next, const bat *bid, const bat *sid, const 
bat *gid, const bat *eid, const bat *hid);
 str IDentifier(identifier *retval, str *in);
-ssize_t IDfromString(const char *src, size_t *len, identifier *retval, bool 
external);
 str IDprelude(void *ret);
-ssize_t IDtoString(str *retval, size_t *len, const char *handle, bool 
external);
 str ILIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate, const bit 
*anti);
 str ILIKEjoin1(bat *r1, const bat *lid, const bat *rid, const bat *slid, const 
bat *srid, const bit *nil_matches, const lng *estimate, const bit *anti);
 str ILIKEjoin_esc(bat *r1, bat *r2, const bat *lid, const bat *rid, const str 
*esc, const bat *slid, const bat *srid, const bit *nil_matches, const lng 
*estimate, const bit *anti);
@@ -1334,18 +1322,14 @@ str INET_inet(inet *d, const inet *s);
 str INET_isnil(bit *retval, const inet *val);
 str INETabbrev(str *retval, const inet *val);
 str INETbroadcast(inet *retval, const inet *val);
-int INETcompare(const inet *l, const inet *r);
-ssize_t INETfromString(const char *src, size_t *len, inet **retval, bool 
external);
 str INEThost(str *retval, const inet *val);
 str INEThostmask(inet *retval, const inet *val);
 str INETmasklen(int *retval, const inet *val);
 str INETnetmask(inet *retval, const inet *val);
 str INETnetwork(inet *retval, const inet *val);
 str INETnew(inet *retval, str *in);
-const inet *INETnull(void);
 str INETsetmasklen(inet *retval, const inet *val, const int *msk);
 str INETtext(str *retval, const inet *val);
-ssize_t INETtoString(str *retval, size_t *len, const inet *handle, bool 
external);
 str INSPECTatom_names(bat *ret);
 str INSPECTatom_sizes(bat *ret);
 str INSPECTatom_sup_names(bat *ret);
@@ -1397,7 +1381,6 @@ str JSONfilterArray_int(json *ret, json 
 str JSONfilterArray_lng(json *ret, json *j, lng *index);
 str JSONfilterArray_sht(json *ret, json *j, sht *index);
 str JSONfold(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-ssize_t JSONfromString(const char *src, size_t *len, json *x, bool external);
 str JSONgroupStr(str *ret, const bat *bid);
 str JSONisarray(bit *ret, json *j);
 str JSONisobject(bit *ret, json *j);
@@ -1417,7 +1400,6 @@ str JSONresultSet(json *res, bat *u, bat
 str JSONstr2json(json *ret, str *j);
 str JSONsubjson(bat *retval, bat *bid, bat *gid, bat *eid, bit *skipnils);
 str JSONsubjsoncand(bat *retval, bat *bid, bat *gid, bat *eid, bat *id, bit 
*skip_nils);
-ssize_t JSONtoString(str *s, size_t *len, const char *src, bool external);
 str JSONunfold(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str JSONvalueArray(json *ret, json *arg);
 str JSONvalueTable(bat *ret, json *j);
@@ -2036,7 +2018,6 @@ int TYPE_identifier;
 int TYPE_json;
 int TYPE_uuid;
 int TYPE_xml;
-ssize_t URLfromString(const char *src, size_t *len, str *u, bool external);
 str URLgetAnchor(str *retval, url *val);
 str URLgetBasename(str *retval, url *t);
 str URLgetContext(str *retval, url *val);
@@ -2054,25 +2035,17 @@ str URLnew(url *u, str *val);
 str URLnew3(url *u, str *protocol, str *server, str *file);
 str URLnew4(url *u, str *protocol, str *server, int *port, str *file);
 str URLnoop(url *u, url *val);
-ssize_t URLtoString(str *s, size_t *len, const char *src, bool external);
-int UUIDcompare(const uuid *l, const uuid *r);
-ssize_t UUIDfromString(const char *svalue, size_t *len, uuid **retval, bool 
external);
 str UUIDgenerateUuid(uuid **retval);
 str UUIDgenerateUuid(uuid *retval);
 str UUIDgenerateUuidInt(uuid **retval, int *d);
 str UUIDgenerateUuidInt(uuid *retval, int *d);
-BUN UUIDhash(const void *u);
 str UUIDisaUUID(bit *retval, str *u);
-const uuid *UUIDnull(void);
 str UUIDprelude(void *ret);
-uuid *UUIDread(uuid *u, stream *s, size_t cnt);
 str UUIDstr2uuid(uuid **retval, str *s);
 str UUIDstr2uuid(uuid *retval, str *s);
-ssize_t UUIDtoString(str *retval, size_t *len, const uuid *value, bool 
external);
 str UUIDuuid2str(str *retval, const uuid *u);
 str UUIDuuid2str(str *retval, uuid **u);
 str UUIDuuid2uuid(uuid *retval, uuid *s);
-gdk_return UUIDwrite(const uuid *u, stream *s, size_t cnt);
 str WLCaction(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str WLCappend(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str WLCcatalog(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
@@ -2109,7 +2082,6 @@ str XMLelement(xml *ret, str *name, xml 
 str XMLelementSmall(xml *ret, str *name, xml *val);
 str XMLepilogue(void *ret);
 str XMLforest(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-ssize_t XMLfromString(const char *src, size_t *len, xml *x, bool external);
 str XMLisdocument(bit *x, str *s);
 str XMLparse(xml *x, str *doccont, str *s, str *option);
 str XMLpi(xml *x, str *target, str *s);
@@ -2117,7 +2089,6 @@ str XMLprelude(void *ret);
 size_t XMLquotestring(const char *s, char *buf, size_t len);
 str XMLroot(xml *x, xml *v, str *version, str *standalone);
 str XMLstr2xml(xml *x, const char **s);
-ssize_t XMLtoString(str *s, size_t *len, const char *src, bool external);
 size_t XMLunquotestring(const char **p, char q, char *buf);
 str XMLxml2str(str *s, xml *x);
 str XMLxml2xml(xml *x, xml *s);
@@ -2208,8 +2179,6 @@ str closeRef;
 void clrDeclarations(MalBlkPtr mb);
 void clrFunction(InstrPtr p);
 void clrInstruction(InstrPtr p);
-ssize_t color_fromstr(const char *colorStr, size_t *len, color **c, bool 
external);
-ssize_t color_tostr(char **colorStr, size_t *len, const color *c, bool 
external);
 str columnBindRef;
 str columnRef;
 str comment_onRef;
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -30,7 +30,8 @@ geometryHasM(int info)
 {
        return (info & 0x01);
 }
-static wkb wkb_nil = { ~0, 0 };
+static const wkb wkb_nil = { ~0, 0 };
+static const wkba wkba_nil = {.itemsNum = ~0};
 
 static wkb *
 wkbNULLcopy(void)
@@ -2311,7 +2312,7 @@ mbrFromGeos(const GEOSGeom geosGeometry)
 
        /* if input is null or GEOSEnvelope created exception then create a 
nill mbr */
        if (!geosGeometry || (envelope = GEOSEnvelope(geosGeometry)) == NULL) {
-               *geomMBR = *mbrNULL();
+               *geomMBR = mbrNIL;
                return geomMBR;
        }
 
@@ -2487,6 +2488,8 @@ mbrFromMBR(mbr **w, mbr **src)
        return MAL_SUCCEED;
 }
 
+static ssize_t wkbTOSTR(char **geomWKT, size_t *len, const void *GEOMWKB, bool 
external);
+
 str
 wkbFromWKB(wkb **w, wkb **src)
 {
@@ -2495,7 +2498,7 @@ wkbFromWKB(wkb **w, wkb **src)
                throw(MAL, "calc.wkb", SQLSTATE(HY013) MAL_MALLOC_FAIL);
 
        if (is_wkb_nil(*src)) {
-               **w = *wkbNULL();
+               **w = wkb_nil;
        } else {
                (*w)->len = (*src)->len;
                (*w)->srid = (*src)->srid;
@@ -3676,7 +3679,7 @@ wkbInteriorRings(wkba **geomArray, wkb *
        if (is_wkb_nil(*geomWKB)) {
                if ((*geomArray = GDKmalloc(wkba_size(~0))) == NULL)
                        throw(MAL, "geom.InteriorRings", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-               **geomArray = *wkbaNULL();
+               **geomArray = wkba_nil;
                return MAL_SUCCEED;
        }
 
@@ -4549,7 +4552,7 @@ wkbMBR(mbr **geomMBR, wkb **geomWKB)
        if (is_wkb_nil(*geomWKB)) {
                if ((*geomMBR = GDKmalloc(sizeof(mbr))) == NULL)
                        throw(MAL, "geom.MBR", SQLSTATE(HY013) MAL_MALLOC_FAIL);
-               **geomMBR = *mbrNULL();
+               **geomMBR = mbrNIL;
                return MAL_SUCCEED;
        }
        //check if the geometry is empty
@@ -4559,7 +4562,7 @@ wkbMBR(mbr **geomMBR, wkb **geomWKB)
        if (empty) {
                if ((*geomMBR = GDKmalloc(sizeof(mbr))) == NULL)
                        throw(MAL, "geom.MBR", SQLSTATE(HY013) MAL_MALLOC_FAIL);
-               **geomMBR = *mbrNULL();
+               **geomMBR = mbrNIL;
                return MAL_SUCCEED;
        }
 
@@ -4593,7 +4596,7 @@ wkbBox2D(mbr **box, wkb **point1, wkb **
        if (is_wkb_nil(*point1) || is_wkb_nil(*point2)) {
                if ((*box = GDKmalloc(sizeof(mbr))) == NULL)
                        throw(MAL, "geom.MakeBox2D", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-               **box = *mbrNULL();
+               **box = mbrNIL;
                return MAL_SUCCEED;
        }
        //check input not point geometries
@@ -4995,6 +4998,8 @@ wkbCoordinateFromWKB(dbl *coordinateValu
        return ret;
 }
 
+static ssize_t mbrFROMSTR(const char *src, size_t *len, void **ATOM, bool 
external);
+
 str
 mbrFromString(mbr **w, const char **src)
 {
@@ -5002,7 +5007,7 @@ mbrFromString(mbr **w, const char **src)
        char *errbuf;
        str ex;
 
-       if (mbrFROMSTR(*src, &len, w, false) >= 0)
+       if (mbrFROMSTR(*src, &len, (void **) w, false) >= 0)
                return MAL_SUCCEED;
        GDKfree(*w);
        *w = NULL;
@@ -5038,7 +5043,7 @@ ordinatesMBR(mbr **res, flt *minX, flt *
        if ((*res = GDKmalloc(sizeof(mbr))) == NULL)
                throw(MAL, "geom.mbr", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        if (is_flt_nil(*minX) || is_flt_nil(*minY) || is_flt_nil(*maxX) || 
is_flt_nil(*maxY))
-               **res = *mbrNULL();
+               **res = mbrNIL;
        else {
                (*res)->xmin = *minX;
                (*res)->ymin = *minY;
@@ -5054,9 +5059,10 @@ ordinatesMBR(mbr **res, flt *minX, flt *
 
 /* Creates the string representation (WKT) of a WKB */
 /* return length of resulting string. */
-ssize_t
-wkbTOSTR(char **geomWKT, size_t *len, const wkb *geomWKB, bool external)
-{
+static ssize_t
+wkbTOSTR(char **geomWKT, size_t *len, const void *GEOMWKB, bool external)
+{
+       const wkb *geomWKB = GEOMWKB;
        char *wkt = NULL;
        size_t dstStrLen = 5;   /* "nil" */
 
@@ -5113,9 +5119,10 @@ wkbTOSTR(char **geomWKT, size_t *len, co
        return 1;
 }
 
-ssize_t
-wkbFROMSTR(const char *geomWKT, size_t *len, wkb **geomWKB, bool external)
-{
+static ssize_t
+wkbFROMSTR(const char *geomWKT, size_t *len, void **GEOMWKB, bool external)
+{
+       wkb **geomWKB = (wkb **) GEOMWKB;
        size_t parsedBytes;
        str err;
 
@@ -5134,9 +5141,10 @@ wkbFROMSTR(const char *geomWKT, size_t *
        return (ssize_t) parsedBytes;
 }
 
-BUN
-wkbHASH(const wkb *w)
-{
+static BUN
+wkbHASH(const void *W)
+{
+       const wkb *w = W;
        int i;
        BUN h = 0;
 
@@ -5148,15 +5156,16 @@ wkbHASH(const wkb *w)
 }
 
 /* returns a pointer to a null wkb */
-const wkb *
+static const void *
 wkbNULL(void)
 {
-       return (&wkb_nil);
-}
-
-int
-wkbCOMP(const wkb *l, const wkb *r)
-{
+       return &wkb_nil;
+}
+
+static int
+wkbCOMP(const void *L, const void *R)
+{
+       const wkb *l = L, *r = R;
        int len = l->len;
 
        if (len != r->len)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to