summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaa <kaa@disroot.org>2025-06-18 03:01:20 -0700
committerkaa <kaa@disroot.org>2025-06-18 03:01:20 -0700
commitf7c2841cdd3d5854ad4a1a53cb9627f4ba8dc805 (patch)
treeb54c65ff0d05eaf517a9ab2a201e13c557e63df2
parentc117eed0679d42c359b9529ef288afbe7191cc15 (diff)
file gulping
-rwxr-xr-xd.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/d.h b/d.h
new file mode 100755
index 0000000..84115dd
--- /dev/null
+++ b/d.h
@@ -0,0 +1,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;
+}