blob: 84115dda6feac113b9079f314889079f7adc6144 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum {
bufsize = 0x20,
};
static char *
getall(FILE *in)
{
char buf[bufsize];
static char *contents = NULL;
int len = 0, read;
while ((read = fread(buf, 1, bufsize, in)) > 0) {
len += read;
contents = realloc(contents, len);
memmove(&contents[len-read], buf, read);
}
contents = realloc(contents, len + 1);
contents[len] = '\0';
return contents;
}
|