commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4356 - gnuradio/branches/developers/trondeau/udp/gnur


From: trondeau
Subject: [Commit-gnuradio] r4356 - gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io
Date: Fri, 2 Feb 2007 07:45:05 -0700 (MST)

Author: trondeau
Date: 2007-02-02 07:45:05 -0700 (Fri, 02 Feb 2007)
New Revision: 4356

Modified:
   
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
Log:
Removed unnecessary buffer. Cut out a mem alloc, memcpy, and should be cleaner 
and faster.

Modified: 
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
 2007-02-02 03:24:57 UTC (rev 4355)
+++ 
gnuradio/branches/developers/trondeau/udp/gnuradio-core/src/lib/io/gr_udp_source.cc
 2007-02-02 14:45:05 UTC (rev 4356)
@@ -129,8 +129,6 @@
   ssize_t bytes_to_receive=0, bytes_received=0, bytes=0;
   ssize_t total_bytes = (ssize_t)(d_itemsize*noutput_items);
 
-  char *buff = new char[d_mtu];
-
   #if SRC_VERBOSE
   printf("\nEntered udp_source\n");
   #endif
@@ -142,8 +140,8 @@
     bytes_received = bytes_to_receive;
 
     #if SRC_VERBOSE
-    printf("\tTemp buff size: %d (bytes_to_receive: %d) (noutput_items: 
%d)\n", 
-          d_residual, bytes_received, noutput_items);
+    printf("\tTemp buff size: %d  offset: %d (bytes_to_receive: %d) 
(noutput_items: %d)\n", 
+          d_residual, d_temp_offset, bytes_received, noutput_items);
     #endif
 
     // Increment pointer
@@ -157,7 +155,7 @@
   while((bytes_received < total_bytes) && (bytes>-1)) {
     // get the data into our output buffer and record the number of bytes
     // This is a non-blocking call with a timeout set in the constructor
-    bytes = recv(d_socket, buff, d_mtu, 0);  // get the entire MTU or the rest 
of what's available
+    bytes = recv(d_socket, d_temp_buff, d_mtu, 0);  // get the entire MTU or 
the rest of what's available
 
     // Check if there was a problem; forget it if the operation just timed out
     if(bytes == -1) {
@@ -177,11 +175,10 @@
       bytes_to_receive = std::min(bytes, total_bytes-bytes_received);
 
       // copy the number of bytes we want to look at here
-      memcpy(out, buff, bytes_to_receive);    
+      memcpy(out, d_temp_buff, bytes_to_receive);    
 
       d_residual=bytes-bytes_to_receive;                      // save the 
number of bytes stored
-      d_temp_offset=0;                                        // reset buffer 
index
-      memcpy(d_temp_buff, buff+bytes_to_receive, d_residual); // save the 
rest, if we need to
+      d_temp_offset=bytes_to_receive;                         // reset buffer 
index
 
       // keep track of the total number of bytes received
       bytes_received += bytes_to_receive;
@@ -199,7 +196,5 @@
   printf("Total Bytes Received: %d (noutput_items=%d)\n", bytes_received, 
noutput_items);
   #endif
 
-  delete [] buff;
-
   return noutput_items;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]