diff options
author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-09-01 02:03:13 +0000 |
---|---|---|
committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-09-01 02:03:13 +0000 |
commit | 9fe394a5afa0356b4e00a448b82e8b00370dc1f5 (patch) | |
tree | 5b6fae2f140db4adcb1f7ebd0a4c8dbb994713ce | |
parent | 863fb82e76eba16742cab87c085dd7b08639bcb9 (diff) | |
download | uClibc-alpine-9fe394a5afa0356b4e00a448b82e8b00370dc1f5.tar.bz2 uClibc-alpine-9fe394a5afa0356b4e00a448b82e8b00370dc1f5.tar.xz |
Sync with trunk.
-rw-r--r-- | include/malloc.h | 3 | ||||
-rw-r--r-- | test/string/string.c | 31 |
2 files changed, 33 insertions, 1 deletions
diff --git a/include/malloc.h b/include/malloc.h index 610c47dc3..6b8e1ad91 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -174,6 +174,7 @@ extern void malloc_stats(FILE *file); #define M_MMAP_THRESHOLD -3 #define M_MMAP_MAX -4 #define M_CHECK_ACTION -5 +#define M_PERTURB -6 /* General SVID/XPG interface to tunable parameters. */ extern int mallopt __MALLOC_P ((int __param, int __val)); @@ -182,7 +183,7 @@ extern int mallopt __MALLOC_P ((int __param, int __val)); #ifdef __cplusplus -}; /* end of extern "C" */ +} /* end of extern "C" */ #endif #endif /* malloc.h */ diff --git a/test/string/string.c b/test/string/string.c index e23ee6279..60caddf99 100644 --- a/test/string/string.c +++ b/test/string/string.c @@ -337,6 +337,9 @@ test_strncat (void) (void) strncat (one, "gh", 2); equal (one, "abcdgh", 12); /* Count and length equal. */ + + (void) strncat (one, "ij", (size_t)-1); /* set sign bit in count */ + equal (one, "abcdghij", 13); } static void @@ -357,6 +360,8 @@ test_strncmp (void) check (strncmp ("abce", "abc", 3) == 0, 11); /* Count == length. */ check (strncmp ("abcd", "abce", 4) < 0, 12); /* Nudging limit. */ check (strncmp ("abc", "def", 0) == 0, 13); /* Zero count. */ + check (strncmp ("abc", "", (size_t)-1) > 0, 14); /* set sign bit in count */ + check (strncmp ("abc", "abc", (size_t)-2) == 0, 15); } static void @@ -423,6 +428,29 @@ test_strlen (void) } static void +test_strnlen (void) +{ + it = "strnlen"; + check (strnlen ("", 10) == 0, 1); /* Empty. */ + check (strnlen ("a", 10) == 1, 2); /* Single char. */ + check (strnlen ("abcd", 10) == 4, 3); /* Multiple chars. */ + check (strnlen ("foo", (size_t)-1) == 3, 4); /* limits of n. */ + + { + char buf[4096]; + int i; + char *p; + for (i=0; i < 0x100; i++) + { + p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i; + strcpy (p, "OK"); + strcpy (p+3, "BAD/WRONG"); + check (strnlen (p, 100) == 2, 5+i); + } + } +} + +static void test_strchr (void) { it = "strchr"; @@ -1329,6 +1357,9 @@ main (void) /* strlen. */ test_strlen (); + /* strnlen. */ + test_strnlen (); + /* strchr. */ test_strchr (); |