aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/vinum
diff options
context:
space:
mode:
authorGreg Lehey <grog@FreeBSD.org>2003-05-23 01:15:01 +0000
committerGreg Lehey <grog@FreeBSD.org>2003-05-23 01:15:01 +0000
commit7db14b2ff2d7d212d653dc631abfd87cffcb6943 (patch)
tree5de33ac8765881402b9e0ee096906a82c1aba330 /sys/dev/vinum
parentd026346c869fb7b5492f3d7dac7c6e2aee93a899 (diff)
Notes
Diffstat (limited to 'sys/dev/vinum')
-rw-r--r--sys/dev/vinum/vinummemory.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sys/dev/vinum/vinummemory.c b/sys/dev/vinum/vinummemory.c
index f83d69630247..b4e9a4376a3d 100644
--- a/sys/dev/vinum/vinummemory.c
+++ b/sys/dev/vinum/vinummemory.c
@@ -33,7 +33,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
- * $Id: vinummemory.c,v 1.30 2003/04/28 02:54:43 grog Exp $
+ * $Id: vinummemory.c,v 1.31 2003/05/23 01:08:36 grog Exp $
* $FreeBSD$
*/
@@ -104,27 +104,40 @@ basename(char *file)
return ++f; /* skip the / */
}
+#ifdef VINUMDEBUG
+void
+expand_table(void **table, int oldsize, int newsize, char *file, int line)
+#else
void
expand_table(void **table, int oldsize, int newsize)
+#endif
{
if (newsize > oldsize) {
int *temp;
int s;
s = splhigh();
+#ifdef VINUMDEBUG
+ temp = (int *) MMalloc(newsize, file, line); /* allocate a new table */
+#else
temp = (int *) Malloc(newsize); /* allocate a new table */
+#endif
CHECKALLOC(temp, "vinum: Can't expand table\n");
bzero((char *) temp, newsize); /* clean it all out */
if (*table != NULL) { /* already something there, */
bcopy((char *) *table, (char *) temp, oldsize); /* copy it to the old table */
+#ifdef VINUMDEBUG
+ FFree(*table, file, line);
+#else
Free(*table);
+#endif
}
*table = temp;
splx(s);
}
}
-#ifdef VINUMDEBUG /* XXX debug */
+#ifdef VINUMDEBUG
#define MALLOCENTRIES 16384
int malloccount = 0;
int highwater = 0; /* highest index ever allocated */
@@ -172,8 +185,7 @@ MMalloc(int size, char *file, int line)
malloced[i].size = size;
malloced[i].line = line;
malloced[i].address = result;
- bcopy(f, malloced[i].file, min(strlen(f), MCFILENAMELEN - 1));
- malloced[i].file[MCFILENAMELEN - 1] = '\0';
+ strlcpy(malloced[i].file, f, MCFILENAMELEN);
}
if (malloccount > highwater)
highwater = malloccount;
@@ -208,8 +220,7 @@ FFree(void *mem, char *file, int line)
freeinfo[lastfree].size = malloced[i].size;
freeinfo[lastfree].line = line;
freeinfo[lastfree].address = mem;
- bcopy(f, freeinfo[lastfree].file, min(strlen(f), MCFILENAMELEN - 1));
- freeinfo[lastfree].file[MCFILENAMELEN - 1] = '\0';
+ bcopy(f, freeinfo[lastfree].file, MCFILENAMELEN);
if (++lastfree == FREECOUNT)
lastfree = 0;
}
@@ -251,7 +262,7 @@ vinum_mallocinfo(caddr_t data)
m->size = malloced[ent].size;
m->line = malloced[ent].line;
m->seq = malloced[ent].seq;
- bcopy(malloced[ent].file, m->file, MCFILENAMELEN);
+ strlcpy(m->file, malloced[ent].file, MCFILENAMELEN);
return 0;
}