File: test6.c

package info (click to toggle)
uthash 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,788 kB
  • sloc: ansic: 9,838; makefile: 178; perl: 88; sh: 37; cpp: 30
file content (45 lines) | stat: -rw-r--r-- 871 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include "libut.h"

void dump(UT_vector *v) {
  printf("len: %d\n", utvector_len(v));
  UT_string *p=NULL;
  while ( (p=(UT_string*)utvector_next(v,p))) printf("%s\n",utstring_body(p));
}

int main() {
  int i; UT_string *p;
  UT_vector v; utvector_init(&v, utstring_mm);
  UT_string s; utstring_init(&s);
  for(i=0; i<10; i++) {
    utstring_printf(&s, ".");
    utvector_push(&v, &s);
  }
  dump(&v);

  printf("extend\n");
  p = utvector_extend(&v);
  utstring_printf(p,"extended element");
  dump(&v);

  printf("pop\n");
  utvector_pop(&v);
  dump(&v);

  printf("clear\n");
  utvector_clear(&v);
  dump(&v);

  printf("push\n");
  utstring_new(p);
  utstring_printf(p,"allocated utstring");
  utvector_push(&v, p);
  utstring_free(p);
  dump(&v);

  printf("done1\n");
  utvector_fini(&v);
  printf("done2\n");
  utstring_done(&s);
  return 0;
}