From: Vlad Krupin Date: Mon, 31 Dec 2001 12:52:34 +0000 (+0000) Subject: Now dbase_pack() actually truncates the resulting .dbf file to the right X-Git-Tag: PRE_ISSET_PATCH~344 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=543077d9153900fc13b00829bba7e345459175f0;p=php Now dbase_pack() actually truncates the resulting .dbf file to the right size (possibly fixing bug #6852 #3). @Make dbase_pack() truncate the file to the right size. (Vlad) --- diff --git a/ext/dbase/dbf_rec.c b/ext/dbase/dbf_rec.c index 44d90b69d2..11ee63b107 100644 --- a/ext/dbase/dbf_rec.c +++ b/ext/dbase/dbf_rec.c @@ -125,6 +125,12 @@ void pack_dbf(dbhead_t *dbh) rec_cnt--; } free(cp); + + /* Try to truncate the file to the right size. */ + if (ftruncate(dbh->db_fd, out_off) != 0) { + php_error(E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there."); + } + if (rec_cnt == 0) dbh->db_records = new_cnt; }