From a69fe8289448367e85f6e6bc4cb96d077d23f9be Mon Sep 17 00:00:00 2001 From: grog Date: Sat, 10 Apr 1999 08:11:44 +0000 Subject: When VINUMDEBUG is set, add function basename() to return the base name of a file. Used by MMalloc and lockdrive. --- sys/dev/vinum/vinummemory.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/vinum/vinummemory.c b/sys/dev/vinum/vinummemory.c index a20b2b0..f066310 100644 --- a/sys/dev/vinum/vinummemory.c +++ b/sys/dev/vinum/vinummemory.c @@ -88,6 +88,19 @@ LongJmp(jmp_buf buf, int retval) panic("Invalid longjmp"); longjmp(buf, retval); } + +/* find the base name of a path name */ +char * +basename(char *file) +{ + char *f = rindex(file, '/'); /* chop off dirname if present */ + + if (f == NULL) + return file; + else + return ++f; /* skip the / */ +} + #else #define LongJmp longjmp /* just use the kernel function */ #endif @@ -145,12 +158,8 @@ MMalloc(int size, char *file, int line) Debugger("Malloc overlap"); } if (result) { - char *f = rindex(file, '/'); /* chop off dirname if present */ + char *f = basename(file); - if (f == NULL) - f = file; - else - f++; /* skip the / */ i = malloccount++; total_malloced += size; microtime(&malloced[i].time); -- cgit v1.1