X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=tests%2Fexample-vector.c;h=62e79318e4f45cae9bc69730dca81da91605265b;hb=e938f8c45fd191d96da48f65262e4efcfada7805;hp=48403fcb106302ee50e0804c92c8f2d9c973f28b;hpb=d8c1ccad095640b40192055bff9ad37e98216970;p=rrq%2Frrqmisc.git diff --git a/tests/example-vector.c b/tests/example-vector.c index 48403fc..62e7931 100644 --- a/tests/example-vector.c +++ b/tests/example-vector.c @@ -7,7 +7,7 @@ #include #include #include -#include "vector.h" +#include "Vector.h" typedef struct _ipslot { int family; @@ -16,7 +16,7 @@ typedef struct _ipslot { } ipslot; static struct { - vector data; + Vector data; int fill; } table; @@ -99,9 +99,9 @@ static void add_entry(ipslot *tmp) { ipslot *p = (ipslot *) malloc( sizeof( ipslot ) ); memmove( p, tmp, sizeof( ipslot ) ); if ( table.data.size == table.fill ) { - (void) vector_resize( &table.data, table.fill + 256, 0, 0 ); + (void) Vector_resize( &table.data, table.fill + 256, 0, 0 ); } - vector_set( &table.data, table.fill++, p ); + Vector_set( &table.data, table.fill++, p ); } static void load_file(const char *filename) { @@ -122,42 +122,40 @@ static void load_file(const char *filename) { } } -static int int_reclaim(vector *pv,unsigned long index,void *item,void *data) { +static int int_reclaim(Vector *pv,unsigned long index,void *item,void *data) { return 0; } -static int dumpitem(const unsigned long index,const void *item) { +static void dumpitem(const VectorIndex index,const void *item) { fprintf( stdout, "[%ld] %p\n", index, item ); - return 0; } -static int dump_ipslot(const unsigned long index,const void *item) { +static void dump_ipslot(const VectorIndex index,const void *item) { static char buffer[100]; ipslot *ip = (ipslot*) item; const char *p = inet_ntop( ip->family, ip->data, buffer, 100 ); fprintf( stdout, "[%ld] %s/%d\n", index, p, ip->bits ); - return 0; } int main(int argc,char **argv) { - vector test = { 0 }; - vector_resize( &test, 100, 0, 0 ); - vector_set( &test, 5, (void*) 500 ); - vector_set( &test, 55, (void*) 600 ); - vector_resize( &test, 300, 0, 0 ); - vector_set( &test, 55, (void*) 650 ); - vector_resize( &test, 30000, 0, 0 ); - vector_set( &test, 22255, (void*) 26 ); - vector_dump( &test, dumpitem ); - vector_resize( &test, 100, int_reclaim, 0 ); - vector_set( &test, 5, (void*) 2 ); - vector_dump( &test, dumpitem ); + Vector test = { 0 }; + Vector_resize( &test, 100, 0, 0 ); + Vector_set( &test, 5, (void*) 500 ); + Vector_set( &test, 55, (void*) 600 ); + Vector_resize( &test, 300, 0, 0 ); + Vector_set( &test, 55, (void*) 650 ); + Vector_resize( &test, 30000, 0, 0 ); + Vector_set( &test, 22255, (void*) 26 ); + Vector_dump( &test, dumpitem ); + Vector_resize( &test, 100, int_reclaim, 0 ); + Vector_set( &test, 5, (void*) 2 ); + Vector_dump( &test, dumpitem ); int i; for ( i = 1; i < argc; i++ ) { load_file( argv[ i ] ); } - vector_dump( &table.data, dump_ipslot ); + Vector_dump( &table.data, dump_ipslot ); return 0; }