We also define an allocator that always crashes on out of memory: you * will discover that in most programs designed to run for a long time, that * are not libraries, trying to recover from out of memory is often futile * and at the same time makes the whole program terrible. */
| 134 | * are not libraries, trying to recover from out of memory is often futile |
| 135 | * and at the same time makes the whole program terrible. */ |
| 136 | void *chatMalloc(size_t size) { |
| 137 | void *ptr = malloc(size); |
| 138 | if (ptr == NULL) { |
| 139 | perror("Out of memory"); |
| 140 | exit(1); |
| 141 | } |
| 142 | return ptr; |
| 143 | } |
| 144 | |
| 145 | /* Also aborting realloc(). */ |
| 146 | void *chatRealloc(void *ptr, size_t size) { |
no outgoing calls
no test coverage detected