use free() instead of delete() when realloc is used