save 1640 .text bytes in MKSH_SMALL case by not inlining strdupx, strndupx

This commit is contained in:
tg
2008-10-28 14:51:06 +00:00
parent 88d7b7d08b
commit bf3194e937
2 changed files with 35 additions and 2 deletions

22
misc.c
View File

@@ -6,7 +6,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.88 2008/10/28 14:32:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.89 2008/10/28 14:51:06 tg Exp $");
#undef USE_CHVT
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
@@ -1422,3 +1422,23 @@ stristr(const char *b, const char *l)
}
#endif
#endif
#ifdef MKSH_SMALL
char *
strndup_(const char *src, size_t len, Area *ap)
{
char *dst = NULL;
if (src != NULL) {
dst = alloc(++len, ap);
strlcpy(dst, src, len);
}
return (dst);
}
char *
strdup_(const char *src, Area *ap)
{
return (src == NULL ? NULL : strndup_(src, strlen(src), ap));
}
#endif