Browse Source

Rename tp->cp to tp->cm.

master
Richard Nyberg 19 years ago
parent
commit
350f8adc2d
2 changed files with 17 additions and 17 deletions
  1. +16
    -16
      btpd/content.c
  2. +1
    -1
      btpd/torrent.h

+ 16
- 16
btpd/content.c View File

@@ -33,14 +33,14 @@ cm_start(struct torrent *tp)
+ ceil(tp->meta.npieces / 8.0) + ceil(tp->meta.npieces / 8.0)
+ tp->meta.npieces * ceil(tp->meta.piece_length / (double)(1 << 17)); + tp->meta.npieces * ceil(tp->meta.piece_length / (double)(1 << 17));


tp->cp = btpd_calloc(mem, 1); tp->cm = btpd_calloc(mem, 1);
tp->cp->piece_map = (uint32_t *)(tp->cp + 1); tp->cm->piece_map = (uint32_t *)(tp->cm + 1);
tp->cp->piece_field = (uint8_t *)(tp->cp->piece_map + tp->meta.npieces); tp->cm->piece_field = (uint8_t *)(tp->cm->piece_map + tp->meta.npieces);
tp->cp->block_field = tp->cp->piece_field tp->cm->block_field = tp->cm->piece_field
+ (size_t)ceil(tp->meta.npieces / 8.0); + (size_t)ceil(tp->meta.npieces / 8.0);


evtimer_set(&tp->cp->done, done_cb, tp); evtimer_set(&tp->cm->done, done_cb, tp);
evtimer_add(&tp->cp->done, (& (struct timeval) { 0, 0 })); evtimer_add(&tp->cm->done, (& (struct timeval) { 0, 0 }));


return 0; return 0;
} }
@@ -48,42 +48,42 @@ cm_start(struct torrent *tp)
void void
cm_stop(struct torrent *tp) cm_stop(struct torrent *tp)
{ {
evtimer_add(&tp->cp->done, (& (struct timeval) { 0, 0 })); evtimer_add(&tp->cm->done, (& (struct timeval) { 0, 0 }));
} }


int int
cm_full(struct torrent *tp) cm_full(struct torrent *tp)
{ {
return tp->cp->npieces == tp->meta.npieces; return tp->cm->npieces == tp->meta.npieces;
} }


uint8_t * uint8_t *
cm_get_piece_field(struct torrent *tp) cm_get_piece_field(struct torrent *tp)
{ {
return tp->cp->piece_field; return tp->cm->piece_field;
} }


uint8_t * uint8_t *
cm_get_block_field(struct torrent *tp, uint32_t piece) cm_get_block_field(struct torrent *tp, uint32_t piece)
{ {
return tp->cp->block_field + return tp->cm->block_field +
piece * (size_t)ceil(tp->meta.piece_length / (double)(1 << 17)); piece * (size_t)ceil(tp->meta.piece_length / (double)(1 << 17));
} }


int int
cm_has_piece(struct torrent *tp, uint32_t piece) cm_has_piece(struct torrent *tp, uint32_t piece)
{ {
return has_bit(tp->cp->piece_field, piece); return has_bit(tp->cm->piece_field, piece);
} }


int int
cm_put_block(struct torrent *tp, uint32_t piece, uint32_t block, cm_put_block(struct torrent *tp, uint32_t piece, uint32_t block,
const char *data) const char *data)
{ {
set_bit(tp->cp->block_field + set_bit(tp->cm->block_field +
piece * (size_t)ceil(tp->meta.piece_length / (double)(1 << 17)), piece * (size_t)ceil(tp->meta.piece_length / (double)(1 << 17)),
block); block);
tp->cp->nblocks++; tp->cm->nblocks++;
return 0; return 0;
} }


@@ -104,8 +104,8 @@ static
void test_cb(int fd, short type, void *arg) void test_cb(int fd, short type, void *arg)
{ {
struct test *t = arg; struct test *t = arg;
set_bit(t->pc->tp->cp->piece_field, t->pc->index); set_bit(t->pc->tp->cm->piece_field, t->pc->index);
t->pc->tp->cp->npieces++; t->pc->tp->cm->npieces++;
dl_on_ok_piece(t->pc); dl_on_ok_piece(t->pc);
free(t); free(t);
} }
@@ -122,7 +122,7 @@ cm_test_piece(struct piece *pc)
uint32_t uint32_t
cm_get_npieces(struct torrent *tp) cm_get_npieces(struct torrent *tp)
{ {
return tp->cp->npieces; return tp->cm->npieces;
} }


off_t off_t


+ 1
- 1
btpd/torrent.h View File

@@ -44,7 +44,7 @@ struct torrent {


enum torrent_state state; enum torrent_state state;


struct content *cp; struct content *cm;
struct tracker *tr; struct tracker *tr;


BTPDQ_ENTRY(torrent) entry; BTPDQ_ENTRY(torrent) entry;


||||||
x
 
000:0
Loading…
Cancel
Save