helly Sun Nov 3 10:09:49 2002 EDT Modified files: /php4/ext/dba dba_cdb.c Log: -fixed -use *e*malloc Index: php4/ext/dba/dba_cdb.c diff -u php4/ext/dba/dba_cdb.c:1.14 php4/ext/dba/dba_cdb.c:1.15 --- php4/ext/dba/dba_cdb.c:1.14 Thu Sep 19 00:18:20 2002 +++ php4/ext/dba/dba_cdb.c Sun Nov 3 10:09:49 2002 @@ -12,11 +12,12 @@ | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Sascha Schumann <[EMAIL PROTECTED]> | + | Authors: Sascha Schumann <[EMAIL PROTECTED]> | + | Marcus Boerger <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: dba_cdb.c,v 1.14 2002/09/19 04:18:20 sas Exp $ */ +/* $Id: dba_cdb.c,v 1.15 2002/11/03 15:09:49 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -54,10 +55,10 @@ switch (info->mode) { case DBA_READER: gmode = O_RDONLY; break; - /* currently not supported: */ + /* currently not supported: */ #if 0 - case DBA_WRITER: - gmode = O_RDWR; break; + case DBA_WRITER: + gmode = O_RDWR; break; #endif default: return FAILURE; @@ -68,8 +69,8 @@ return FAILURE; } - cdb = malloc(sizeof *cdb); - memset(cdb, 0, sizeof *cdb); + cdb = emalloc(sizeof(dba_cdb)); + memset(cdb, 0, sizeof(dba_cdb)); cdb_init(&cdb->c, fd); cdb->fd = fd; @@ -85,7 +86,7 @@ /* cdb_free does not close associated fd */ cdb_free(&cdb->c); close(cdb->fd); - free(cdb); + efree(cdb); } DBA_FETCH_FUNC(cdb) @@ -96,13 +97,13 @@ if (cdb_find(&cdb->c, key, keylen) == 1) { len = cdb_datalen(&cdb->c); - new_entry = emalloc(len); + new_entry = emalloc(len+1); if (cdb_read(&cdb->c, new_entry, len, cdb_datapos(&cdb->c)) == -1) { - free(new_entry); + efree(new_entry); return NULL; } - + new_entry[len] = 0; if (newlen) *newlen = len; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php