diff options
author | joe <joe@FreeBSD.org> | 2000-06-17 11:09:24 +0000 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2000-06-17 11:09:24 +0000 |
commit | 4946ded616808163421971bd6648d16bb43c1020 (patch) | |
tree | efd55bb42d8342e76d0520fb606d34e1c942b650 /lib/libc/gen/strtofflags.c | |
parent | 72dbbe24eb4f86ab6c34fcc8f32b2bcabd1151e3 (diff) | |
download | FreeBSD-src-4946ded616808163421971bd6648d16bb43c1020.zip FreeBSD-src-4946ded616808163421971bd6648d16bb43c1020.tar.gz |
Modify strtofflags so that it returns a malloced string instead of a
pointer to a static buffer.
Diffstat (limited to 'lib/libc/gen/strtofflags.c')
-rw-r--r-- | lib/libc/gen/strtofflags.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c index d9d2dc4..4c9e8d5 100644 --- a/lib/libc/gen/strtofflags.c +++ b/lib/libc/gen/strtofflags.c @@ -44,6 +44,7 @@ static const char rcsid[] = #include <sys/stat.h> #include <stddef.h> +#include <stdlib.h> #include <string.h> static struct { @@ -71,6 +72,7 @@ static struct { { "nouunlnk", UF_NOUNLINK, 0 }, { "nouunlink", UF_NOUNLINK, 0 } }; +#define longestflaglen 12 #define nmappings (sizeof(mapping) / sizeof(mapping[0])) /* @@ -82,11 +84,14 @@ char * fflagstostr(flags) u_long flags; { - static char string[128]; + char *string; char *sp, *dp; u_long setflags; int i; + if ((string = (char *)malloc(nmappings * (longestflaglen + 1))) == NULL) + return (NULL); + setflags = flags; dp = string; for (i = 0; i < nmappings; i++) { |