Allocation can fail only on out of memory. In such case they return NULL and leave the state as before call.