]> mj.ucw.cz Git - libucw.git/blobdiff - lib/db-emul.c
Fixed a nasty bug in hash table allocation. HASH_AUTO_POOL must use
[libucw.git] / lib / db-emul.c
index 533c996f156e2d4e8b572181f59ef66d43269b25..62540de84592e70b70245ac13891fd77bdbefbf3 100644 (file)
@@ -1,16 +1,19 @@
 /*
- *     Sherlock Library -- SDBM emulator at top of GDBM
+ *     UCW Library -- SDBM emulator at top of GDBM
  *
- *     (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1999 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
+#include "lib/lib.h"
+#include "lib/db.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "lib.h"
-#include "db.h"
-
 #include <gdbm.h>
 
 struct sdbm {
@@ -39,7 +42,7 @@ sdbm_close(struct sdbm *d)
 {
   sdbm_rewind(d);
   gdbm_close(d->db);
-  free(d);
+  xfree(d);
 }
 
 static int
@@ -110,7 +113,7 @@ sdbm_fetch(struct sdbm *d, byte *key, uns keylen, byte *val, uns *vallen)
   if (!V.dptr)
     return 0;
   rc = sdbm_put_user(V.dptr, V.dsize, val, vallen);
-  free(V.dptr);
+  xfree(V.dptr);
   return rc ? SDBM_ERROR_TOO_LARGE : 1;
 }
 
@@ -119,7 +122,7 @@ sdbm_rewind(struct sdbm *d)
 {
   if (d->prevkey.dptr)
     {
-      free(d->prevkey.dptr);
+      xfree(d->prevkey.dptr);
       d->prevkey.dptr = NULL;
     }
 }
@@ -132,7 +135,7 @@ sdbm_get_next(struct sdbm *d, byte *key, uns *keylen, byte *val, uns *vallen)
   if (d->prevkey.dptr)
     {
       K = gdbm_nextkey(d->db, d->prevkey);
-      free(d->prevkey.dptr);
+      xfree(d->prevkey.dptr);
     }
   else
     K = gdbm_firstkey(d->db);