Public » Mercurial » dirstate
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

exit if malloc fails

Changeset 5ec4f546596e

Parent 83212a2426f6

by Profile picture of Benjamin PollackBenjamin Pollack

Changes to one file · Browse files at 5ec4f546596e Showing diff from parent 83212a2426f6 Diff from another changeset...

Change 1 of 2 Show Entire File dirstate.c Stacked
 
25
26
27
 
 
 
 
 
 
 
28
29
30
 
40
41
42
43
 
44
45
46
 
25
26
27
28
29
30
31
32
33
34
35
36
37
 
47
48
49
 
50
51
52
53
@@ -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);