Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't malloc data if mysmysocket->remaining equals 0, just return.
authorNavarrop <Pierre.Navarro@imag.fr>
Tue, 20 Sep 2011 11:39:35 +0000 (13:39 +0200)
committerNavarrop <Pierre.Navarro@imag.fr>
Tue, 20 Sep 2011 11:39:35 +0000 (13:39 +0200)
src/surf/ns3/ns3_simulator.cc

index c705984..9509298 100644 (file)
@@ -131,12 +131,15 @@ static void receive_callback(Ptr<Socket> localSocket){
 }
 
 static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
-       uint8_t *data = (uint8_t*)malloc(sizeof(uint8_t)*txSpace);
        MySocket* mysocket = get_my_socket(localSocket);
+
        if (mysocket->remaining == 0){
                  //all data was already buffered (and socket was already closed), just return
                  return;
        }
+
+       uint8_t *data = (uint8_t*)malloc(sizeof(uint8_t)*txSpace);
+
        while (mysocket->sentBytes < mysocket->totalBytes
                        && localSocket->GetTxAvailable () > 0)
        {