(trunk libT) use alloca() for allocating the block array in updateBlockRequests()
This commit is contained in:
parent
85f853f214
commit
ac3ec2db39
|
@ -16,6 +16,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
#include <event2/buffer.h>
|
||||
#include <event2/bufferevent.h>
|
||||
#include <event2/event.h>
|
||||
|
@ -1743,7 +1745,7 @@ updateBlockRequests( tr_peermsgs * msgs )
|
|||
int i;
|
||||
int n;
|
||||
const int numwant = msgs->desiredRequestCount - msgs->peer->pendingReqsToPeer;
|
||||
tr_block_index_t * blocks = tr_new( tr_block_index_t, numwant );
|
||||
tr_block_index_t * blocks = alloca( sizeof( tr_block_index_t ) * numwant );
|
||||
|
||||
tr_peerMgrGetNextRequests( msgs->torrent, msgs->peer, numwant, blocks, &n );
|
||||
|
||||
|
@ -1753,8 +1755,6 @@ updateBlockRequests( tr_peermsgs * msgs )
|
|||
blockToReq( msgs->torrent, blocks[i], &req );
|
||||
protocolSendRequest( msgs, &req );
|
||||
}
|
||||
|
||||
tr_free( blocks );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue