1984not-GmbH / molch

An implementation of the axolotl ratchet based on libsodium.
Other
23 stars 3 forks source link

Macros for allocation failures #78

Closed FSMaxB closed 7 years ago

FSMaxB commented 8 years ago

After every allocation it has to be checked if the allocation was successful and an error thrown in case it wasn't.

It would be nice to have some kind of macro that does this in one step. It could be added to return_status:

#define throw_on_failed_alloc(pointer) if (pointer == NULL) {\
         throw(ALLOCATION_FAILED, "Failed to allocate memory.");\
    }
FSMaxB commented 8 years ago
FSMaxB commented 7 years ago

After the C++ porting, all allocation failures will automatically throw exceptions, so no need to manually check for them.