(trunk libT) use alloca() for allocating the block array in updateBlockRequests()

This commit is contained in:
Jordan Lee 2011-04-05 00:53:57 +00:00
parent 85f853f214
commit ac3ec2db39
1 changed files with 3 additions and 3 deletions

View File

@ -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 );
}
}