2 * Test program that uses std::string object from more than one thread and
3 * that also triggers a call to __GI_strlen() (from inside strdup()). See also
4 * https://bugs.kde.org/show_bug.cgi?id=326091.
11 #if defined(__FreeBSD__)
17 char* list2byteArray()
19 size_t data_size
= 24;
20 char *data
= new char[data_size
];
21 for (size_t i
= 0; i
< data_size
; i
++)
23 data
[data_size
- 1] = 0;
24 char *ret
= strdup(data
);
31 char *data
= list2byteArray();
37 void *fillTable(void *ptr
)
39 for (int i
= 0; i
< 100; i
++) {
40 std::string
id("000");
41 id
.append(1, 'a' + i
);
42 std::list
<std::string
> record
;
43 record
.push_back("some data");
50 int main(int argc
, char* argv
[])
54 for (int i
= 0; i
< sizeof(thread
)/sizeof(thread
[0]); i
++) {
55 int ret
= pthread_create(&thread
[i
], NULL
, &fillTable
, NULL
);
57 fprintf(stderr
, "Failed to create thread %d: %d\n", i
, ret
);
62 for (int i
= 0; i
< sizeof(thread
)/sizeof(thread
[0]); i
++) {
63 int ret
= pthread_join(thread
[i
], NULL
);
65 fprintf(stderr
, "Failed to join thread %d: %d\n", i
, ret
);