re_alloc() thread safe*

Thread safe for re_alloc() function. Logic conditions changed for some CHECK
blocks.

* There is an error "pthread_mutex_lock.c:62: __pthread_mutex_lock:
Assertion `mutex->__data.__owner == 0' failed.". Google says that there the
problem can be starting from thread buffer ending to compiller =(