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
|
#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 *t;
UT_vector v; utvector_init(&v, utstring_mm);
UT_string s; utstring_init(&s);
for(i=0; i<16; i++) {
utstring_printf(&s, ".");
utvector_push(&v, &s);
}
dump(&v);
printf("extend\n");
t = (UT_string*)utvector_extend(&v);
utstring_bincpy(t, "hello", 5);
dump(&v);
utvector_fini(&v);
utstring_done(&s);
return 0;
}
|