diff options
author | Karel Zak <kzak@redhat.com> | 2006-12-07 00:26:19 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2006-12-07 00:26:19 +0100 |
commit | d26aa358f42df65da50014ad62b1a78f22c97400 (patch) | |
tree | bf961bf31e4f704fc997acde938d292c4abdc588 /mount/sundries.c | |
parent | 2cccd0ff2b26c782dbd05d589b7695cab5e17458 (diff) | |
download | util-linux-old-d26aa358f42df65da50014ad62b1a78f22c97400.tar.gz |
Imported from util-linux-2.12h tarball.
Diffstat (limited to 'mount/sundries.c')
-rw-r--r-- | mount/sundries.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/mount/sundries.c b/mount/sundries.c index e331f5d8..af5bb884 100644 --- a/mount/sundries.c +++ b/mount/sundries.c @@ -73,6 +73,7 @@ xstrconcat2 (const char *s, const char *t) { return res; } +/* frees its first arg - typical use: s = xstrconcat3(s,t,u); */ char * xstrconcat3 (const char *s, const char *t, const char *u) { char *res; @@ -84,9 +85,11 @@ xstrconcat3 (const char *s, const char *t, const char *u) { strcpy(res, s); strcat(res, t); strcat(res, u); + free((void *) s); return res; } +/* frees its first arg - typical use: s = xstrconcat4(s,t,u,v); */ char * xstrconcat4 (const char *s, const char *t, const char *u, const char *v) { char *res; @@ -100,6 +103,7 @@ xstrconcat4 (const char *s, const char *t, const char *u, const char *v) { strcat(res, t); strcat(res, u); strcat(res, v); + free((void *) s); return res; } @@ -269,19 +273,18 @@ matching_opts (const char *options, const char *test_opts) { we return unmodified. */ char * canonicalize (const char *path) { - char *canonical; + char canonical[PATH_MAX+2]; - if (path == NULL) - return NULL; + if (path == NULL) + return NULL; - if (streq(path, "none") || streq(path, "proc") || streq(path, "devpts")) - return xstrdup(path); + if (streq(path, "none") || + streq(path, "proc") || + streq(path, "devpts")) + return xstrdup(path); - canonical = xmalloc (PATH_MAX+2); - - if (myrealpath (path, canonical, PATH_MAX+1)) - return canonical; + if (myrealpath (path, canonical, PATH_MAX+1)) + return xstrdup(canonical); - free(canonical); - return xstrdup(path); + return xstrdup(path); } |