1
0
mirror of git://erdgeist.org/opentracker synced 2025-01-12 07:50:52 +00:00
opentracker/ot_vector.h

37 lines
1.3 KiB
C
Raw Normal View History

/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2007-12-20 05:59:34 +00:00
It is considered beerware. Prost. Skol. Cheers or whatever.
2008-10-28 01:27:22 +00:00
2007-12-20 05:59:34 +00:00
$id$ */
#ifndef OT_VECTOR_H__
#define OT_VECTOR_H__
2007-11-12 01:40:00 +00:00
/* These defines control vectors behaviour */
#define OT_VECTOR_MIN_MEMBERS 2
#define OT_VECTOR_GROW_RATIO 2
#define OT_VECTOR_SHRINK_THRESH 4
#define OT_VECTOR_SHRINK_RATIO 2
2007-11-12 01:40:00 +00:00
#define OT_PEER_BUCKET_MINCOUNT 512
#define OT_PEER_BUCKET_MAXCOUNT 256
typedef struct {
2024-04-14 22:39:02 +00:00
void *data;
size_t size;
size_t space;
} ot_vector;
2024-04-14 22:39:02 +00:00
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);
ot_peer *vector_find_or_insert_peer(ot_vector *vector, ot_peer const *peer, size_t peer_size, int *exactmatch);
2024-04-14 22:39:02 +00:00
int vector_remove_peer(ot_vector *vector, ot_peer const *peer, size_t peer_size);
void vector_remove_torrent(ot_vector *vector, ot_torrent *match);
/* For ot_clean.c */
2024-04-14 22:39:02 +00:00
void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size);
void vector_fixup_peers(ot_vector *vector, size_t peer_size);
void vector_clean_list(ot_vector *vector, int num_buckets);
#endif