Usage of z_stream_s structure: zalloc must return Z_NULL if there is not enough memory for the object.
Firebird code, if I understood correctly, assign to zalloc throw-based allocation func:
void* allocFunc(void*, uInt items, uInt size)
return MemoryPool::globalAlloc(items * size ALLOC_ARGS); //thow ?
In deflateInit, for example, has five calls of zalloc function and has rollback of initialization if second (and next) call of zalloc return nullptr.