From 8900cc0dd980cb08a0af957a1d0dd849bf3c2ac6 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Tue, 6 Nov 2007 11:58:32 +0000 Subject: No one can get access to buckets now without locking them. Also split up the trackerlogic.c-monster in functional sub-units. HEADS UP: this code is untested and not considered stable. --- ot_vector.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ot_vector.h (limited to 'ot_vector.h') diff --git a/ot_vector.h b/ot_vector.h new file mode 100644 index 0000000..8863855 --- /dev/null +++ b/ot_vector.h @@ -0,0 +1,26 @@ +/* This software was written by Dirk Engling + It is considered beerware. Prost. Skol. Cheers or whatever. */ + +#ifndef __OT_VECTOR_H__ +#define __OT_VECTOR_H__ + +#include "trackerlogic.h" + +#define OT_VECTOR_MIN_MEMBERS 4 +#define OT_VECTOR_GROW_RATIO 8 +#define OT_VECTOR_SHRINK_THRESH 6 +#define OT_VECTOR_SHRINK_RATIO 4 +typedef struct { + void *data; + size_t size; + size_t space; +} ot_vector; + +void *binary_search( const void * const key, const void * base, const size_t member_count, const size_t member_size, + size_t compare_size, int *exactmatch ); +void *vector_find_or_insert( ot_vector *vector, void *key, size_t member_size, size_t compare_size, int *exactmatch ); + +int vector_remove_peer( ot_vector *vector, ot_peer *peer, int hysteresis ); +void vector_remove_torrent( ot_vector *vector, ot_torrent *match ); + +#endif \ No newline at end of file -- cgit v1.2.3