+ if (info->prev)
+ info->prev->next = info->next;
+ if (info->next)
+ info->next->prev = info->prev;
+ if (info == mem_start)
+ mem_start = info->next;
+
+ free(info);
+}
+
+void *util_memory_r(void *ptrn, size_t byte, unsigned int line, const char *file) {
+ struct memblock_t *oldinfo = NULL;
+
+ struct memblock_t *newinfo;
+
+ if (!ptrn)
+ return util_memory_a(byte, line, file);
+ if (!byte) {
+ util_memory_d(ptrn, line, file);
+ return NULL;
+ }
+
+ oldinfo = ((struct memblock_t*)ptrn - 1);
+ newinfo = ((struct memblock_t*)malloc(sizeof(struct memblock_t) + byte));
+
+ util_debug("MEM", "reallocation: % 8u -> %u (bytes) address 0x%08X -> 0x%08X @ %s:%u\n", oldinfo->byte, byte, ptrn, (void*)(newinfo+1), file, line);
+
+ /* new data */
+ if (!newinfo) {
+ util_memory_d(oldinfo+1, line, file);
+ return NULL;
+ }
+
+ /* copy old */
+ memcpy(newinfo+1, oldinfo+1, oldinfo->byte);
+
+ /* free old */
+ if (oldinfo->prev)
+ oldinfo->prev->next = oldinfo->next;
+ if (oldinfo->next)
+ oldinfo->next->prev = oldinfo->prev;
+ if (oldinfo == mem_start)
+ mem_start = oldinfo->next;
+
+ /* fill info */
+ newinfo->line = line;
+ newinfo->byte = byte;
+ newinfo->file = file;
+ newinfo->prev = NULL;
+ newinfo->next = mem_start;
+ if (mem_start)
+ mem_start->prev = newinfo;
+ mem_start = newinfo;
+
+ mem_ab -= oldinfo->byte;
+ mem_ab += newinfo->byte;
+
+ free(oldinfo);
+
+ return newinfo+1;