[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3456 - gnuradio/branches/developers/jcorgan/wip/ezdop
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r3456 - gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/ezdop |
Date: |
Sat, 2 Sep 2006 01:13:31 -0600 (MDT) |
Author: jcorgan
Date: 2006-09-02 01:13:31 -0600 (Sat, 02 Sep 2006)
New Revision: 3456
Modified:
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/ezdop/ezdop.cc
Log:
Fixed memory leak by using boost::shared_array<>
Modified: gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/ezdop/ezdop.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/ezdop/ezdop.cc
2006-09-02 06:41:31 UTC (rev 3455)
+++ gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/ezdop/ezdop.cc
2006-09-02 07:13:31 UTC (rev 3456)
@@ -22,6 +22,9 @@
// Application specific includes
#include "ezdop.h"
+// Boost includes
+#include <boost/shared_array.hpp>
+
// System includes (FIXME: autoconf these)
#include <cassert>
#include <cstdio>
@@ -219,6 +222,8 @@
return rd;
}
+typedef boost::shared_array<unsigned char> unsigned_char_sarray;
+
int ezdop::read_iq(complex<float> *buffer, unsigned int samples)
{
assert(d_online);
@@ -226,19 +231,18 @@
assert(buffer);
// 4 phases, d_rate samples per phase, 2 bytes per sample
- int bufsize = 8*d_rate*samples;
- unsigned char *raw = new unsigned char[bufsize];
+ int raw_size = 8*d_rate*samples;
+ unsigned_char_sarray raw = unsigned_char_sarray(new unsigned
char[raw_size]);
// Read until required bytes are read. Will block until bytes arrive.
int rd = 0;
- while (rd < bufsize)
- rd += read_raw(&raw[rd], bufsize-rd);
+ while (rd < raw_size)
+ rd += read_raw(&raw[rd], raw_size-rd);
// Iterate through read bytes and invoke state machine
int i = 0, j = 0; // i index inputs, j indexes outputs
- unsigned char ant;
- while (i < bufsize) {
+ while (i < raw_size) {
unsigned char ch = raw[i++];
if (d_state == ST_LO) {
d_val = ch; // Save lo byte
@@ -292,6 +296,5 @@
d_state = ST_LO; // Switch states
};
- delete raw;
return j;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3456 - gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/ezdop,
jcorgan <=