Changeset 5ec4f546596e…
Parent 83212a2426f6…
by Benjamin Pollack
Changes to one file · Browse files at 5ec4f546596e Showing diff from parent 83212a2426f6 Diff from another changeset...
@@ -25,6 +25,13 @@ unsigned __entries_length;
} dirstate;
+void *xalloc(size_t n, size_t size)
+{
+ void *p = calloc(n, size);
+ if (!p) exit(1);
+ return p;
+}
+
void dirstate_add_entry(dirstate *d, const direntry *e)
{
if (d->num_entries == d->__entries_length)
@@ -40,7 +47,7 @@ direntry e;
FILE *f = fopen(path, "r");
if (!f) return NULL;
- dirstate *d = calloc(1, sizeof(dirstate));
+ dirstate *d = xalloc(1, sizeof(dirstate));
fread(&d->parent1, sizeof(char), HASH_LENGTH, f);
fread(&d->parent2, sizeof(char), HASH_LENGTH, f);
|
Loading...