Hi,

I ran into a problem when doing some tests where I piped 1e6 samples
through a filter. The problem is, gr_head() can only go as far as
MAX_INT when limiting data. However, I don't really see a reason why the
counter shouldn't be an unsigned long. Otherwise, such applications
would require some workarounds with vectors or otherwise, which I find a
bit ugly. Here's the patch. Made against #11663 in SVN.

MB


-- 
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-3790
Fax: +49 721 608-6071
www.cel.kit.edu

KIT -- University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

Index: gnuradio-core/src/lib/general/gr_head.h
===================================================================
--- gnuradio-core/src/lib/general/gr_head.h	(revision 11663)
+++ gnuradio-core/src/lib/general/gr_head.h	(working copy)
@@ -38,11 +38,11 @@
 
 class gr_head : public gr_sync_block
 {
-  friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
-  gr_head (size_t sizeof_stream_item, int nitems);
+  friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long nitems);
+  gr_head (size_t sizeof_stream_item, unsigned long nitems);
 
-  int	d_nitems;
-  int	d_ncopied_items;
+  unsigned long	d_nitems;
+  unsigned long	d_ncopied_items;
 
  public:
   int work (int noutput_items,
@@ -53,7 +53,7 @@
 };
 
 gr_head_sptr
-gr_make_head (size_t sizeof_stream_item, int nitems);
+gr_make_head (size_t sizeof_stream_item, unsigned long nitems);
 
 
 #endif /* INCLUDED_GR_HEAD_H */
Index: gnuradio-core/src/lib/general/gr_head.i
===================================================================
--- gnuradio-core/src/lib/general/gr_head.i	(revision 11663)
+++ gnuradio-core/src/lib/general/gr_head.i	(working copy)
@@ -22,7 +22,7 @@
 
 GR_SWIG_BLOCK_MAGIC(gr,head);
 
-gr_head_sptr gr_make_head(size_t sizeof_stream_item, int nitems);
+gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long nitems);
 
 class gr_head : public gr_block {
   gr_head();
Index: gnuradio-core/src/lib/general/gr_head.cc
===================================================================
--- gnuradio-core/src/lib/general/gr_head.cc	(revision 11663)
+++ gnuradio-core/src/lib/general/gr_head.cc	(working copy)
@@ -27,7 +27,7 @@
 #include <gr_io_signature.h>
 #include <string.h>
 
-gr_head::gr_head (size_t sizeof_stream_item, int nitems)
+gr_head::gr_head (size_t sizeof_stream_item, unsigned long nitems)
   : gr_sync_block ("head",
 		   gr_make_io_signature (1, 1, sizeof_stream_item),
 		   gr_make_io_signature (1, 1, sizeof_stream_item)),
@@ -36,7 +36,7 @@
 }
 
 gr_head_sptr
-gr_make_head (size_t sizeof_stream_item, int nitems)
+gr_make_head (size_t sizeof_stream_item, unsigned long nitems)
 {
   return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems));
 }
@@ -49,7 +49,7 @@
   if (d_ncopied_items >= d_nitems)
     return -1;				// Done!
 
-  unsigned n = std::min (d_nitems - d_ncopied_items, noutput_items);
+  unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long) noutput_items);
   
   if (n == 0)
     return 0;

Attachment: pgpb8gOUnXcRC.pgp
Description: PGP signature

_______________________________________________
Patch-gnuradio mailing list
Patch-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/patch-gnuradio

Reply via email to