Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions ext/dba/libflatfile/flatfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ int flatfile_delete(flatfile *dba, datum key_datum) {

/* read in the key name */
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}

if (size == num && !memcmp(buf, key, size)) {
php_stream_seek(dba->fp, pos, SEEK_SET);
Expand All @@ -150,9 +147,6 @@ int flatfile_delete(flatfile *dba, datum key_datum) {
}
/* read in the value */
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}
}
efree(buf);
return FAILURE;
Expand Down Expand Up @@ -180,9 +174,7 @@ int flatfile_findkey(flatfile *dba, datum key_datum) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}

if (size == num) {
if (!memcmp(buf, key, size)) {
ret = 1;
Expand All @@ -198,9 +190,6 @@ int flatfile_findkey(flatfile *dba, datum key_datum) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}
}
efree(buf);
return ret;
Expand All @@ -226,9 +215,7 @@ datum flatfile_firstkey(flatfile *dba) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}

if (*(buf) != 0) {
dba->CurrentFlatFilePos = php_stream_tell(dba->fp);
res.dptr = buf;
Expand All @@ -244,9 +231,6 @@ datum flatfile_firstkey(flatfile *dba) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}
}
efree(buf);
res.dptr = NULL;
Expand Down Expand Up @@ -274,9 +258,7 @@ datum flatfile_nextkey(flatfile *dba) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}

if (!php_stream_gets(dba->fp, buf, 15)) {
break;
}
Expand All @@ -286,9 +268,7 @@ datum flatfile_nextkey(flatfile *dba) {
buf = erealloc(buf, buf_size);
}
num = php_stream_read(dba->fp, buf, num);
if (num < 0) {
break;
}

if (*(buf)!=0) {
dba->CurrentFlatFilePos = php_stream_tell(dba->fp);
res.dptr = buf;
Expand Down