Debian Codegraph @

t/ffi/string_array.c

raw
1 #include "libtest.h"
2 #include <string.h>
3
4 EXTERN const char *
5 get_string_from_array(const char **array, int index)
6 {
7 static char buffer[512];
8 if(array[index] == NULL)
9 return NULL;
10 strcpy(buffer, array[index]);
11 return buffer;
12 }
13
14 EXTERN const char **
15 onetwothree3()
16 {
17 static char *buffer[4] = {
18 "one",
19 "two",
20 "three"
21 };
22 return (const char **) buffer;
23 }
24
25 EXTERN const char **
26 onetwothree4()
27 {
28 static char *buffer[4] = {
29 "one",
30 "two",
31 "three",
32 NULL
33 };
34 return (const char **) buffer;
35 }
36
37 EXTERN const char **
38 onenullthree3()
39 {
40 static char *buffer[3] = {
41 "one",
42 NULL,
43 "three"
44 };
45 return (const char **) buffer;
46 }
47
48 EXTERN const char **
49 ptrnull()
50 {
51 static char *buffer[1] = {
52 NULL
53 };
54 return (const char **) buffer;
55 }
56
57 EXTERN void
58 string_array_arg_update(char **arg)
59 {
60 arg[0] = "one";
61 arg[1] = "two";
62 }