From 03c4a1934a26f547f93dee14f3127df399528821 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 12 Jul 2008 17:56:37 +0000 Subject: [PATCH] for MKSH_SMALL, reduce code size, even at cost of performance --- misc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/misc.c b/misc.c index 3612dea..d0af9fe 100644 --- a/misc.c +++ b/misc.c @@ -6,7 +6,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.82 2008/07/12 17:47:21 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.83 2008/07/12 17:56:37 tg Exp $"); #undef USE_CHVT #if defined(TIOCSCTTY) && !defined(MKSH_SMALL) @@ -64,18 +64,6 @@ initctypes(void) } #if defined(MKSH_SMALL) || !HAVE_EXPSTMT -char * -str_save(const char *s, Area *ap) -{ - char *rv = NULL; - - if (s != NULL) { - size_t sz = strlen(s) + 1; - strlcpy(rv = alloc(sz, ap), s, sz); - } - return (rv); -} - char * str_nsave(const char *s, int n, Area *ap) { @@ -85,6 +73,22 @@ str_nsave(const char *s, int n, Area *ap) strlcpy(rv = alloc(n + 1, ap), s, n + 1); return (rv); } + +char * +str_save(const char *s, Area *ap) +{ +#ifdef MKSH_SMALL + return (str_nsave(s, strlen(s), ap)); +#else + char *rv = NULL; + + if (s != NULL) { + size_t sz = strlen(s) + 1; + strlcpy(rv = alloc(sz, ap), s, sz); + } + return (rv); +#endif +} #endif /* called from XcheckN() to grow buffer */