#define gdbm_NEXTKEY(db,key) gdbm_nextkey(db,key)
#define gdbm_EXISTS(db,key) gdbm_exists(db,key)
-typedef datum gdatum;
-
typedef void (*FATALFUNC)();
static int
return -1;
}
+/* GDBM allocates the datum with system malloc() and expects the user
+ * to free() it. So we either have to free() it immediately, or have
+ * perl free() it when it deallocates the SV, depending on whether
+ * perl uses malloc()/free() or not. */
+static void
+output_datum(SV *arg, char *str, int size)
+{
+#if !defined(MYMALLOC) || (defined(MYMALLOC) && defined(PERL_POLLUTE_MALLOC))
+ sv_usepvn(arg, str, size);
+#else
+ sv_setpvn(arg, str, size);
+ safesysfree(str);
+#endif
+}
+
/* Versions of gdbm prior to 1.7x might not have the gdbm_sync,
gdbm_exists, and gdbm_setopt functions. Apparently Slackware
(Linux) 2.1 contains gdbm-1.5 (which dates back to 1991).
CODE:
gdbm_close(db);
-gdatum
+datum
gdbm_FETCH(db, key)
GDBM_File db
datum key
GDBM_File db
datum key
-gdatum
+datum
gdbm_FIRSTKEY(db)
GDBM_File db
-gdatum
+datum
gdbm_NEXTKEY(db, key)
GDBM_File db
datum key
#
datum T_DATUM
-gdatum T_GDATUM
NDBM_File T_PTROBJ
GDBM_File T_PTROBJ
SDBM_File T_PTROBJ
T_DATUM
$var.dptr = SvPV($arg, PL_na);
$var.dsize = (int)PL_na;
-T_GDATUM
- UNIMPLEMENTED
OUTPUT
T_DATUM
- sv_setpvn($arg, $var.dptr, $var.dsize);
-T_GDATUM
- sv_usepvn($arg, $var.dptr, $var.dsize);
+ output_datum($arg, $var.dptr, $var.dsize);
T_PTROBJ
sv_setref_pv($arg, dbtype, (void*)$var);