add h_alloc() which calls errx() on failure and use it for all basic allocation
Rationale: "Basic allocation" refers to things outside of parsing proper, mostly initialization. If such allocations fail, the system is globally emory-starved from which it will likely not recover by returning failure. In this case, terminating the process is in fact the most robust strategy as it may mean the difference between a permanent hang and a temporary crash.
This commit is contained in:
parent
ca1d8df06c
commit
3fc56a0dc3
6 changed files with 30 additions and 29 deletions
|
|
@ -12,10 +12,8 @@
|
|||
HBitWriter *h_bit_writer_new(HAllocator* mm__) {
|
||||
HBitWriter *writer = h_new(HBitWriter, 1);
|
||||
memset(writer, 0, sizeof(*writer));
|
||||
writer->buf = mm__->alloc(mm__, writer->capacity = 8);
|
||||
if (!writer) {
|
||||
return NULL;
|
||||
}
|
||||
writer->buf = h_alloc(mm__, writer->capacity = 8);
|
||||
assert(writer != NULL);
|
||||
memset(writer->buf, 0, writer->capacity);
|
||||
writer->mm__ = mm__;
|
||||
writer->flags = BYTE_BIG_ENDIAN | BIT_BIG_ENDIAN;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue