Changeset: 75c5332a9ab7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=75c5332a9ab7
Modified Files:
gdk/gdk_atoms.c
gdk/gdk_bbp.c
gdk/gdk_private.h
Branch: default
Log Message:
Cleanup: ATOMunknown_add was not used; check result of ATOMunknown_find.
diffs (164 lines):
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -2066,8 +2066,7 @@ int GDKatomcnt = TYPE_str + 1;
* Sometimes a bat descriptor is loaded before the dynamic module
* defining the atom is loaded. To support this an extra set of
* unknown atoms is kept. These can be accessed via the ATOMunknown
- * interface. Adding atoms to this set is done via the ATOMunknown_add
- * function. Finding an (negative) atom index can be done via
+ * interface. Finding an (negative) atom index can be done via
* ATOMunknown_find, which simply adds the atom if it's not in the
* unknown set. The index van be used to find the name of an unknown
* ATOM via ATOMunknown_name. Once an atom becomes known, ie the
@@ -2077,21 +2076,6 @@ int GDKatomcnt = TYPE_str + 1;
static str unknown[MAXATOMS] = { NULL };
int
-ATOMunknown_add(const char *nme)
-{
- int i = 1;
-
- for (; i < MAXATOMS; i++) {
- if (!unknown[i]) {
- unknown[i] = GDKstrdup(nme);
- return -i;
- }
- }
- assert(0);
- return 0;
-}
-
-int
ATOMunknown_del(int i)
{
assert(unknown[-i]);
@@ -2103,14 +2087,24 @@ ATOMunknown_del(int i)
int
ATOMunknown_find(const char *nme)
{
- int i = 1;
+ int i, j = 0;
- for (; i < MAXATOMS; i++) {
- if (unknown[i] && strcmp(unknown[i], nme) == 0) {
- return -i;
- }
+ /* first try to find the atom */
+ for (i = 1; i < MAXATOMS; i++) {
+ if (unknown[i]) {
+ if (strcmp(unknown[i], nme) == 0) {
+ return -i;
+ }
+ } else if (j == 0)
+ j = i;
}
- return ATOMunknown_add(nme);
+ if (j == 0) {
+ /* no space for new atom (shouldn't happen) */
+ return 0;
+ }
+ if ((unknown[j] = GDKstrdup(nme)) == NULL)
+ return 0;
+ return -j;
}
str
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -548,6 +548,9 @@ fixwkbheap(void)
} *nwkb;
char *oldname, *newname;
+ if (utypewkb == 0)
+ GDKfatal("fixwkbheap: no space for wkb atom");
+
for (bid = 1; bid < bbpsize; bid++) {
if ((b = BBP_desc(bid)) == NULL)
continue; /* not a valid BAT */
@@ -1012,9 +1015,10 @@ heapinit(BAT *b, const char *buf, int *h
else if (strcmp(type, "hge") == 0)
havehge = 1;
#endif
- if ((t = ATOMindex(type)) < 0)
- t = ATOMunknown_find(type);
- else if (var != (t == TYPE_void || BATatoms[t].atomPut != NULL))
+ if ((t = ATOMindex(type)) < 0) {
+ if ((t = ATOMunknown_find(type)) == 0)
+ GDKfatal("BBPinit: no space for atom %s", type);
+ } else if (var != (t == TYPE_void || BATatoms[t].atomPut != NULL))
GDKfatal("BBPinit: inconsistent entry in BBP.dir: %s.varsized
mismatch for BAT %d\n", HT, (int) bid);
else if (var && t != 0 ?
ATOMsize(t) < width ||
@@ -3689,54 +3693,6 @@ BBPdiskscan(const char *parent)
return 0;
}
-#if 0
-void
-BBPatom_drop(int atom)
-{
- int i;
- const char *nme = ATOMname(atom);
- int unknown = ATOMunknown_add(nme);
-
- BBPlock();
- for (i = 0; i < (bat) ATOMIC_GET(BBPsize, BBPsizeLock); i++) {
- if (BBPvalid(i)) {
- BAT *b = BBP_desc(i);
-
- if (!b)
- continue;
-
- if (b->ttype == atom)
- b->ttype = unknown;
- }
- }
- BBPunlock();
-}
-
-void
-BBPatom_load(int atom)
-{
- const char *nme;
- int i, unknown;
-
- BBPlock();
- nme = ATOMname(atom);
- unknown = ATOMunknown_find(nme);
- ATOMunknown_del(unknown);
- for (i = 0; i < (bat) ATOMIC_GET(BBPsize, BBPsizeLock); i++) {
- if (BBPvalid(i)) {
- BAT *b = BBP_desc(i);
-
- if (!b)
- continue;
-
- if (b->ttype == unknown)
- b->ttype = atom;
- }
- }
- BBPunlock();
-}
-#endif
-
void
gdk_bbp_reset(void)
{
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -31,11 +31,10 @@ enum heaptype {
__attribute__((__visibility__("hidden")));
__hidden int ATOMisdescendant(int id, int parentid)
__attribute__((__visibility__("hidden")));
-__hidden int ATOMunknown_add(const char *nme)
- __attribute__((__visibility__("hidden")));
__hidden int ATOMunknown_del(int a)
__attribute__((__visibility__("hidden")));
__hidden int ATOMunknown_find(const char *nme)
+ __attribute__ ((__warn_unused_result__))
__attribute__((__visibility__("hidden")));
__hidden str ATOMunknown_name(int a)
__attribute__((__visibility__("hidden")));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list