libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit 80845b4a09b0032d352fb34678e09d03e6f2400c
parent a3feb8c50165995ebc29431f7ec15ada67ddb92f
Author: z3bra <contactatz3bradotorg>
Date:   Sun Feb 25 06:28:18 -0500

Set bitfield on startup

Diffstat:
libeech.c | 4+++-
libeech.h | 1+
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/libeech.c b/libeech.c @@ -500,11 +500,13 @@ glch_loadtorrent(struct torrent *t, char *b, size_t s) bekstr(&t->info, "pieces", 6, &v); memcpy(t->ph, v.off, v.end - v.off); t->pieces = malloc(t->npiece * sizeof(*t->pieces)); + t->bf = malloc(t->npiece / 8 + 1); + memset(t->bf, 0, t->npiece / 8 + 1); for (i = 0; i < t->npiece; i++) { readpiece(t, &t->pieces[i], i); if (!chkpiece(t, &t->pieces[i], i)) { - /* things to do when chksum is valid */ + setbit(t->bf, i); } } diff --git a/libeech.h b/libeech.h @@ -45,6 +45,7 @@ struct torrent { char ih[20]; char tr[PATH_MAX]; char *ph; + char *bf; struct be be; struct be info; struct peer *peers;