loader: factor out guard location setup from Realloc

To simplify and make it easier to read, use ga_Bytes field from guard
structure.
This commit is contained in:
Toomas Soome 2019-09-17 09:47:35 +00:00
parent 3c19311544
commit 144c4ca039
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352439

View File

@ -156,7 +156,9 @@ Realloc(void *ptr, size_t size, const char *file, int line)
if ((res = Malloc(size, file, line)) != NULL) {
if (ptr) {
old = *(size_t *)((char *)ptr - MALLOCALIGN) - MALLOCALIGN;
Guard *g = (Guard *)((char *)ptr - MALLOCALIGN);
old = g->ga_Bytes - MALLOCALIGN;
if (old < size)
bcopy(ptr, res, old);
else