modified: diffout.py
[GalaxyCodeBases.git] / c_cpp / lib / uthash / libut / tests / test6.c
blob694fc0b60cc042371dea28203d07914b9ad5a55b
1 #include <stdio.h>
2 #include "libut.h"
4 void dump(UT_vector *v) {
5 printf("len: %d\n", utvector_len(v));
6 UT_string *p=NULL;
7 while ( (p=(UT_string*)utvector_next(v,p))) printf("%s\n",utstring_body(p));
10 int main() {
11 int i; UT_string *p;
12 UT_vector v; utvector_init(&v, utstring_mm);
13 UT_string s; utstring_init(&s);
14 for(i=0; i<10; i++) {
15 utstring_printf(&s, ".");
16 utvector_push(&v, &s);
18 dump(&v);
20 printf("extend\n");
21 p = utvector_extend(&v);
22 utstring_printf(p,"extended element");
23 dump(&v);
25 printf("pop\n");
26 utvector_pop(&v);
27 dump(&v);
29 printf("clear\n");
30 utvector_clear(&v);
31 dump(&v);
33 printf("push\n");
34 utstring_new(p);
35 utstring_printf(p,"allocated utstring");
36 utvector_push(&v, p);
37 utstring_free(p);
38 dump(&v);
40 printf("done1\n");
41 utvector_fini(&v);
42 printf("done2\n");
43 utstring_done(&s);
44 return 0;