Reimplemented krealloc from old version