Protect local variables in MALLOC/FREE to avoid shadowing

arguments.  Problem reported by David Laight: david@l8s.co.uk.
This commit is contained in:
gmcgarry 2002-07-05 06:54:45 +00:00
parent b15d37b9dc
commit 88d8a7dd2f
1 changed files with 17 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: malloc.h,v 1.77 2002/01/12 00:00:39 nathanw Exp $ */
/* $NetBSD: malloc.h,v 1.78 2002/07/05 06:54:45 gmcgarry Exp $ */
/*
* Copyright (c) 1987, 1993
@ -425,34 +425,34 @@ struct kmembuckets {
#else /* do not collect statistics */
#define MALLOC(space, cast, size, type, flags) \
do { \
register struct kmembuckets *kbp = &bucket[BUCKETINDX((size))]; \
long s = splvm(); \
if (kbp->kb_next == NULL) { \
register struct kmembuckets *__kbp = &bucket[BUCKETINDX((size))]; \
long __s = splvm(); \
if (__kbp->kb_next == NULL) { \
(space) = (cast)malloc((u_long)(size), (type), (flags)); \
} else { \
(space) = (cast)kbp->kb_next; \
kbp->kb_next = *(caddr_t *)(space); \
(space) = (cast)__kbp->kb_next; \
__kbp->kb_next = *(caddr_t *)(space); \
} \
splx(s); \
splx(__s); \
} while (/* CONSTCOND */ 0)
#define FREE(addr, type) \
do { \
register struct kmembuckets *kbp; \
register struct kmemusage *kup = btokup((addr)); \
long s = splvm(); \
if (1 << kup->ku_indx > MAXALLOCSAVE) { \
register struct kmembuckets *__kbp; \
register struct kmemusage *__kup = btokup((addr)); \
long __s = splvm(); \
if (1 << __kup->ku_indx > MAXALLOCSAVE) { \
free((caddr_t)(addr), (type)); \
} else { \
kbp = &bucket[kup->ku_indx]; \
if (kbp->kb_next == NULL) \
kbp->kb_next = (caddr_t)(addr); \
__kbp = &bucket[__kup->ku_indx]; \
if (__kbp->kb_next == NULL) \
__kbp->kb_next = (caddr_t)(addr); \
else \
*(caddr_t *)(kbp->kb_last) = (caddr_t)(addr); \
*(caddr_t *)(__kbp->kb_last) = (caddr_t)(addr); \
*(caddr_t *)(addr) = NULL; \
kbp->kb_last = (caddr_t)(addr); \
__kbp->kb_last = (caddr_t)(addr); \
} \
splx(s); \
splx(__s); \
} while(/* CONSTCOND */ 0)
#endif /* do not collect statistics */