pvector.o: CFLAGS = -Wall -g
pvector.o: pvector.c | pvector.h
-libpvector.a: pvector.o
+#.INTERMEDIATE: pvector.o
+hashvector.o: CFLAGS = -Wall -g
+hashvector.o: hashvector.c | pvector.h hashvector.h
+
+libpvector.a: pvector.o hashvector.o
$(AR) r $@ $^
CLEANRM += libpvector.a
example-pvector: example-pvector.o libpvector.a
CLEANRM += example-pvector
+#.INTERMEDIATE: example-hashvector.o
+example-hashvector: CFLAGS = -Wall -g
+example-hashvector: LDLIBS = libpvector.a
+example-hashvector: example-hashvector.o libpvector.a
+CLEANRM += example-hashvector
+
clean:
rm -f $(CLEANRM)
ipslot *p = (ipslot *) malloc( sizeof( ipslot ) );
memmove( p, tmp, sizeof( ipslot ) );
if ( table.data.size == table.fill ) {
- (void) pvector_resize( &table.data, table.fill + 256, 0 );
+ (void) pvector_resize( &table.data, table.fill + 256, 0, 0 );
}
pvector_set( &table.data, table.fill++, p );
}
}
}
-static int int_reclaim(pvector *pv,int index,void *item) {
- return 1;
+static int int_reclaim(pvector *pv,unsigned long index,void *item,void *data) {
+ return 0;
}
+static int dumpitem(unsigned long index,void *item) {
+ fprintf( stdout, "[%ld] %p\n", index, item );
+ return 0;
+}
+
+static int dump_ipslot(unsigned long index,void *item) {
+ static char buffer[100];
+ ipslot *ip = (ipslot*) item;
+ const char *p = inet_ntop( (ip->bits <= 32)? AF_INET : AF_INET6,
+ ip->data, buffer, 100 );
+
+ fprintf( stdout, "[%ld] %s/%d\n", index, p, ip->bits );
+ return 0;
+}
int main(int argc,char **argv) {
- pvector test;
- pvector_resize( &test, 100, 0 );
+ pvector test = { 0 };
+ pvector_resize( &test, 100, 0, 0 );
pvector_set( &test, 5, (void*) 500 );
pvector_set( &test, 55, (void*) 600 );
//pvector_set( &test, 550, (void*) 800 );
- pvector_resize( &test, 300, 0 );
+ pvector_resize( &test, 300, 0, 0 );
pvector_set( &test, 55, (void*) 650 );
- pvector_resize( &test, 30000, 0 );
+ pvector_resize( &test, 30000, 0, 0 );
pvector_set( &test, 22255, (void*) 26 );
- pvector_resize( &test, 100, int_reclaim );
+ pvector_dump( &test, dumpitem );
+ pvector_resize( &test, 100, int_reclaim, 0 );
pvector_set( &test, 5, (void*) 2 );
+ pvector_dump( &test, dumpitem );
-#if 0
int i;
for ( i = 1; i < argc; i++ ) {
load_file( argv[ i ] );
}
-#endif
+ pvector_dump( &table.data, dump_ipslot );
+
return 0;
}