X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_open.c;h=4caebd394cf156970f622bddb4e12d68513cafba;hb=8380c6e953a15347b40f2c5c4cc57c2daa8b8c63;hp=e92ae5d1b89f7abecf7b25ebd078f29cabe6ce97;hpb=46d2e915a9f864304ee107f9ea35a60b01d3e378;p=rrdtool.git diff --git a/src/rrd_open.c b/src/rrd_open.c index e92ae5d..4caebd3 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.3rc7 Copyright by Tobi Oetiker, 1997-2008 + * RRDtool 1.3rc9 Copyright by Tobi Oetiker, 1997-2008 ***************************************************************************** * rrd_open.c Open an RRD File ***************************************************************************** @@ -34,7 +34,7 @@ #endif /* get the address of the start of this page */ -#if defined USE_MADVISE || defined HAVE_POSIX_FADVISE +#if defined USE_MADVISE || defined HAVE_POSIX_FADVISE #ifndef PAGE_START #define PAGE_START(addr) ((addr)&(~(_page_size-1))) #endif @@ -371,7 +371,7 @@ void rrd_dontneed( #if defined DEBUG && DEBUG > 1 mincore_print(rrd_file, "after"); #endif -#endif /* without madvise and posix_fadvise ist does not make much sense todo anything */ +#endif /* without madvise and posix_fadvise ist does not make much sense todo anything */ } @@ -563,64 +563,3 @@ void rrd_freemem( { free(mem); } - - -/* XXX: FIXME: missing documentation. */ -/*XXX: FIXME should be renamed to rrd_readfile or _rrd_readfile */ - -int /*_rrd_*/ readfile( - const char *file_name, - char **buffer, - int skipfirst) -{ - long writecnt = 0, totalcnt = MEMBLK; - long offset = 0; - FILE *input = NULL; - char c; - - if ((strcmp("-", file_name) == 0)) { - input = stdin; - } else { - if ((input = fopen(file_name, "rb")) == NULL) { - rrd_set_error("opening '%s': %s", file_name, rrd_strerror(errno)); - return (-1); - } - } - if (skipfirst) { - do { - c = getc(input); - offset++; - } while (c != '\n' && !feof(input)); - } - if (strcmp("-", file_name)) { - fseek(input, 0, SEEK_END); - /* have extra space for detecting EOF without realloc */ - totalcnt = (ftell(input) + 1) / sizeof(char) - offset; - if (totalcnt < MEMBLK) - totalcnt = MEMBLK; /* sanitize */ - fseek(input, offset * sizeof(char), SEEK_SET); - } - if (((*buffer) = (char *) malloc((totalcnt + 4) * sizeof(char))) == NULL) { - perror("Allocate Buffer:"); - exit(1); - }; - do { - writecnt += - fread((*buffer) + writecnt, 1, - (totalcnt - writecnt) * sizeof(char), input); - if (writecnt >= totalcnt) { - totalcnt += MEMBLK; - if (((*buffer) = - rrd_realloc((*buffer), - (totalcnt + 4) * sizeof(char))) == NULL) { - perror("Realloc Buffer:"); - exit(1); - }; - } - } while (!feof(input)); - (*buffer)[writecnt] = '\0'; - if (strcmp("-", file_name) != 0) { - fclose(input); - }; - return writecnt; -}