summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authoroster <oster@NetBSD.org>1999-09-04 21:11:21 +0000
committeroster <oster@NetBSD.org>1999-09-04 21:11:21 +0000
commitd8144e5848055549a46399aaa85dd4d3a1c96c3e (patch)
treed367685b2c71f8076da0d7494d18d6810128909c /sys/dev/raidframe
parent4de17692089596a56ff824efc6feba69e4c0b7ea (diff)
More cleanup of unused stuff. This time we nuke a bunch of memory
allocation stuff.
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_debugMem.c271
-rw-r--r--sys/dev/raidframe/rf_debugMem.h61
2 files changed, 4 insertions, 328 deletions
diff --git a/sys/dev/raidframe/rf_debugMem.c b/sys/dev/raidframe/rf_debugMem.c
index b566af13040..e2a5f67a070 100644
--- a/sys/dev/raidframe/rf_debugMem.c
+++ b/sys/dev/raidframe/rf_debugMem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.c,v 1.5 1999/09/04 16:26:30 oster Exp $ */
+/* $NetBSD: rf_debugMem.c,v 1.6 1999/09/04 21:11:21 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -44,7 +44,7 @@
#include "rf_debugMem.h"
#include "rf_general.h"
-static long tot_mem_in_use = 0, max_mem = 0;
+static long tot_mem_in_use = 0;
/* Hash table of information about memory allocations */
#define RF_MH_TABLESIZE 1000
@@ -64,267 +64,6 @@ RF_DECLARE_MUTEX(rf_debug_mem_mutex)
static void memory_hash_insert(void *addr, int size, int line, char *filen);
static int memory_hash_remove(void *addr, int sz);
-#ifndef _KERNEL /* no redzones or "real_" routines in the
- * kernel */
-
- static void rf_redzone_free_failed(void *ptr, int size, int line, char *file);
-
- void *rf_real_redzone_malloc(_size_)
- int _size_;
-{
- char *p;
-
- rf_validate_mh_table();
- p = malloc((_size_) + 16);
- if (p == NULL)
- return (p);
- RF_ASSERT(p);
- *((long *) p) = (_size_);
- ((char *) p)[(_size_) + 8] = '!';
- ((char *) p)[(_size_) + 15] = '!';
- p += 8;
- return (p);
-}
-
-void *
-rf_real_redzone_calloc(_n_, _size_)
- int _n_, _size_;
-{
- char *p;
- int _sz_;
-
- rf_validate_mh_table();
- _sz_ = (_n_) * (_size_);
- p = malloc((_sz_) + 16);
- if (p == NULL)
- return (p);
- bzero(p, (_sz_) + 16);
- *((long *) p) = (_sz_);
- ((char *) p)[(_sz_) + 8] = '!';
- ((char *) p)[(_sz_) + 15] = '!';
- p += 8;
- return (p);
-}
-
-void
-rf_real_redzone_free(p, line, filen)
- char *p;
- int line;
- char *filen;
-{
- unsigned long _size_;
-
- rf_validate_mh_table();
- p -= 8;
- _size_ = *((long *) p);
- if ((((char *) p)[(_size_) + 8] != '!') || (((char *) p)[(_size_) + 15] != '!'))
- rf_redzone_free_failed(p, (_size_), line, filen);
- free(p);
-}
-
-unsigned long rf_mem_alloc = 0;
-
-char *
-rf_real_Malloc(size, line, file)
- int size;
- int line;
- char *file;
-{
- void *pp;
- char *p;
- int tid;
-
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_malloc(pp, size);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG3("Unable to malloc %d bytes at line %d file %s\n", size,
- line, file);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] malloc 0x%lx - 0x%lx (%d) %s %d\n", tid, p, p + size, size,
- file, line);
- }
- if (rf_memDebug)
- rf_record_malloc(p, size, line, file);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-
-char *
-rf_real_MallocAndAdd(size, alist, line, file)
- int size;
- RF_AllocListElem_t *alist;
- int line;
- char *file;
-{
- void *pp;
- char *p;
- int tid;
-
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_malloc(pp, size);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG3("Unable to malloc %d bytes at line %d file %s\n", size,
- line, file);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] malloc+add 0x%lx - 0x%lx (%d) %s %d\n", tid, p, p + size,
- size, file, line);
- }
- if (alist) {
- rf_real_AddToAllocList(alist, pp, size, 0);
- }
- if (rf_memDebug)
- rf_record_malloc(p, size, line, file);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-
-char *
-rf_real_Calloc(nel, elsz, line, file)
- int nel;
- int elsz;
- int line;
- char *file;
-{
- int tid, size;
- void *pp;
- char *p;
-
- size = nel * elsz;
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_calloc(pp, nel, elsz);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG4("Unable to calloc %d objects of size %d at line %d file %s\n",
- nel, elsz, line, file);
- return (NULL);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] calloc 0x%lx - 0x%lx (%d,%d) %s %d\n", tid, p, p + size, nel,
- elsz, file, line);
- }
- if (rf_memDebug) {
- rf_record_malloc(p, size, line, file);
- }
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-
-char *
-rf_real_CallocAndAdd(nel, elsz, alist, line, file)
- int nel;
- int elsz;
- RF_AllocListElem_t *alist;
- int line;
- char *file;
-{
- int tid, size;
- void *pp;
- char *p;
-
- size = nel * elsz;
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_calloc(pp, nel, elsz);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG4("Unable to calloc %d objs of size %d at line %d file %s\n",
- nel, elsz, line, file);
- return (NULL);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] calloc+add 0x%lx - 0x%lx (%d,%d) %s %d\n", tid, p,
- p + size, nel, elsz, file, line);
- }
- if (alist) {
- rf_real_AddToAllocList(alist, pp, size, 0);
- }
- if (rf_memDebug)
- rf_record_malloc(p, size, line, file);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-
-void
-rf_real_Free(p, sz, line, file)
- void *p;
- int sz;
- int line;
- char *file;
-{
- int tid;
-
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] free 0x%lx - 0x%lx (%d) %s %d\n", tid, p, ((char *) p) + sz, sz,
- file, line);
- }
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- if (rf_memAmtDebug) {
- rf_mem_alloc -= sz;
- printf("%lu - size %d %s:%d\n", rf_mem_alloc, sz, file, line);
- }
- if (rf_memDebug) {
- rf_unrecord_malloc(p, sz);
- }
- rf_redzone_free(p);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
-}
-
-void
-rf_validate_mh_table()
-{
- int i, size;
- struct mh_struct *p;
- char *cp;
-
- return;
- for (i = 0; i < RF_MH_TABLESIZE; i++) {
- for (p = mh_table[i]; p; p = p->next)
- if (p->allocated) {
- cp = ((char *) p->address) - 8;
- size = *((long *) cp);
- if ((((char *) cp)[(size) + 8] != '!') || (((char *) cp)[(size) + 15] != '!')) {
- rf_redzone_free_failed(cp, (size), __LINE__, __FILE__);
- }
- }
- }
-}
-
-static void
-rf_redzone_free_failed(ptr, size, line, file)
- void *ptr;
- int size;
- int line;
- char *file;
-{
- RF_ERRORMSG4("Free of 0x%lx (recorded size %d) at %d of %s detected redzone overrun\n", ptr, size, line, file);
- RF_ASSERT(0);
-}
-#endif /* !_KERNEL */
-
void
rf_record_malloc(p, size, line, filen)
void *p;
@@ -460,9 +199,3 @@ memory_hash_remove(addr, sz)
p->allocated = 0;
return (p->size);
}
-
-void
-rf_ReportMaxMem()
-{
- printf("Max memory used: %d bytes\n", (int) max_mem);
-}
diff --git a/sys/dev/raidframe/rf_debugMem.h b/sys/dev/raidframe/rf_debugMem.h
index b546d7f09c8..ccb8c02a7ee 100644
--- a/sys/dev/raidframe/rf_debugMem.h
+++ b/sys/dev/raidframe/rf_debugMem.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.h,v 1.4 1999/02/05 00:06:08 oster Exp $ */
+/* $NetBSD: rf_debugMem.h,v 1.5 1999/09/04 21:11:21 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -41,49 +41,7 @@
#include "rf_alloclist.h"
#include "rf_options.h"
-#ifndef _KERNEL
-
-#ifndef __NetBSD__
-void *malloc(), *calloc();
-#endif
-RF_DECLARE_EXTERN_MUTEX(rf_debug_mem_mutex)
-/*
- * redzone malloc, calloc, and free allocate an extra 16 bytes on each
- * malloc/calloc call to allow tracking of overflows on free.
- */
-
-#if RF_MEMORY_REDZONES > 0
-#define rf_redzone_malloc(_p_,_size_) _p_ = rf_real_redzone_malloc(_size_)
-#define rf_redzone_calloc(_p_,_n_,_size_) _p_ = rf_real_redzone_calloc(_n_,_size_)
-#define rf_redzone_free(_p_) rf_real_redzone_free(_p_, __LINE__, __FILE__)
-#else /* RF_MEMORY_REDZONES > 0 */
-#define rf_redzone_malloc(_p_,_size_) _p_ = malloc(_size_)
-#define rf_redzone_calloc(_p_,_nel_,_size_) _p_ = calloc(_nel_,_size_)
-#define rf_redzone_free(_ptr_) free(_ptr_)
-#endif /* RF_MEMORY_REDZONES > 0 */
-
-#define RF_Malloc(_p_, _size_, _cast_) { \
- _p_ = _cast_ rf_real_Malloc(_size_, __LINE__, __FILE__); \
-}
-
-#define RF_MallocAndAdd(_p_, _size_, _cast_, _alist_) { \
- _p_ = _cast_ rf_real_MallocAndAdd(_size_, _alist_, __LINE__, __FILE__); \
-}
-
-#define RF_Calloc(_p_, _nel_, _elsz_, _cast_) { \
- _p_ = _cast_ rf_real_Calloc(_nel_, _elsz_, __LINE__, __FILE__); \
-}
-
-#define RF_CallocAndAdd(_p_, _nel_, _elsz_, _cast_, _alist_) { \
- _p_ = _cast_ rf_real_CallocAndAdd(_nel_, _elsz_, _alist_, __LINE__, __FILE__); \
-}
-
-#define RF_Free(__p_, _sz_) { \
- rf_real_Free(__p_, _sz_, __LINE__, __FILE__); \
-}
-
-#else /* KERNEL */
-
+#ifdef _KERNEL
#include <sys/types.h>
typedef u_int32_t U32;
#include <sys/malloc.h>
@@ -123,24 +81,9 @@ typedef u_int32_t U32;
#endif /* _KERNEL */
-#ifndef _KERNEL
-void *rf_real_redzone_malloc(int size);
-void *rf_real_redzone_calloc(int n, int size);
-void rf_real_redzone_free(char *p, int line, char *filen);
-char *rf_real_Malloc(int size, int line, char *file);
-char *rf_real_Calloc(int nel, int elsz, int line, char *file);
-void rf_real_Free(void *p, int sz, int line, char *file);
-void rf_validate_mh_table(void);
-#if RF_UTILITY == 0
-char *rf_real_MallocAndAdd(int size, RF_AllocListElem_t * alist, int line, char *file);
-char *rf_real_CallocAndAdd(int nel, int elsz, RF_AllocListElem_t * alist, int line, char *file);
-#endif /* RF_UTILITY == 0 */
-#endif /* !KERNEL */
-
void rf_record_malloc(void *p, int size, int line, char *filen);
void rf_unrecord_malloc(void *p, int sz);
void rf_print_unfreed(void);
int rf_ConfigureDebugMem(RF_ShutdownList_t ** listp);
-void rf_ReportMaxMem(void);
#endif /* !_RF__RF_DEBUGMEM_H_ */