ppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.
[valgrind.git] / memcheck / tests / solaris / strlcpy.c
blob9dd7e13e111fb7a27844967e7c491e42f723331e
1 /* Tests for some interesting cases in non-standard strlcpy(). */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <strings.h>
7 int main(void)
9 size_t copied;
11 char *src = malloc(100);
12 if (src == NULL) {
13 fprintf(stderr, "Memory allocation failure.\n");
14 return 1;
16 strcpy(src, "Hey, dude!");
18 char *dst = malloc(10);
19 if (dst == NULL) {
20 fprintf(stderr, "Memory allocation failure.\n");
21 return 1;
24 /* This is ok. */
25 copied = strlcpy(dst, src, 10);
26 if (copied != 10)
27 fprintf(stderr, "Expected 10 but got %zu for test #1.\n", copied);
29 /* Here dst is not large enough. */
30 copied = strlcpy(dst, src, strlen(src) + 1);
31 if (copied != 10)
32 fprintf(stderr, "Expected 10 but got %zu for test #2.\n", copied);
34 /* This is just a fancy way how to write strlen(src).
35 Undocumented but heavily used. */
36 copied = strlcpy(NULL, src, 0);
37 if (copied != 10)
38 fprintf(stderr, "Expected 10 but got %zu for test #3.\n", copied);
40 /* Source and destination overlap. */
41 strlcpy(src + 9, src, strlen(src) + 1);
42 /* Return value is not checked because function behaviour
43 is undefined in such case (and valgrind's differs). */
45 return 0;