diff options
author | 2009-03-11 05:06:34 +0000 | |
---|---|---|
committer | 2009-03-11 05:06:34 +0000 | |
commit | df24d3be598574ed27f3a2bb6ec322f65562af34 (patch) | |
tree | f56fcafc0d562c2fedf5c1f5c5d6f5daa6751d0f /src/tools/regrep.c | |
parent | 695bdfd04dce5cbbbb6efbb68086a20e83215163 (diff) |
Added new function core_fload() to load a file into an allocated buffer.
Updated src2html, regrep, and chdman tools to use this function where
appropriate.
In chdman, changed -addmeta to -addmetatext or -addmetabin to explicitly
specify the type of data (previous auto-detect was too dangerous).
Diffstat (limited to 'src/tools/regrep.c')
-rw-r--r-- | src/tools/regrep.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/tools/regrep.c b/src/tools/regrep.c index b1d67865d32..255b3b7b701 100644 --- a/src/tools/regrep.c +++ b/src/tools/regrep.c @@ -222,7 +222,8 @@ INLINE int get_unique_index(const summary_file *curfile, int index) int main(int argc, char *argv[]) { astring *dirname = NULL, *tempfilename = NULL, *tempheader = NULL, *tempfooter = NULL; - core_file *tempfile; + UINT32 bufsize; + void *buffer; int listnum; int result; @@ -237,17 +238,10 @@ int main(int argc, char *argv[]) list_count = argc - 3; /* read the template file into an astring */ - if (core_fopen(astring_c(tempfilename), OPEN_FLAG_READ, &tempfile) == FILERR_NONE) + if (core_fload(astring_c(tempfilename), &buffer, &bufsize) == FILERR_NONE) { - UINT64 filesize = core_fsize(tempfile); - void *buffer = malloc(filesize); - if (buffer != NULL) - { - core_fread(tempfile, buffer, filesize); - tempheader = astring_dupch(buffer, filesize); - free(buffer); - } - core_fclose(tempfile); + tempheader = astring_dupch(buffer, bufsize); + free(buffer); } /* verify the template */ |