Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Sep 2019 09:47:35 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352439 - head/stand/libsa
Message-ID:  <201909170947.x8H9lZe6038045@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Tue Sep 17 09:47:35 2019
New Revision: 352439
URL: https://svnweb.freebsd.org/changeset/base/352439

Log:
  loader: factor out guard location setup from Realloc
  
  To simplify and make it easier to read, use ga_Bytes field from guard
  structure.

Modified:
  head/stand/libsa/zalloc_malloc.c

Modified: head/stand/libsa/zalloc_malloc.c
==============================================================================
--- head/stand/libsa/zalloc_malloc.c	Tue Sep 17 09:46:42 2019	(r352438)
+++ head/stand/libsa/zalloc_malloc.c	Tue Sep 17 09:47:35 2019	(r352439)
@@ -156,7 +156,9 @@ Realloc(void *ptr, size_t size, const char *file, int 
 
     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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909170947.x8H9lZe6038045>