aboutsummaryrefslogtreecommitdiff
path: root/src/stateful.c
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-06-05 20:31:06 +0100
committerJamie Bullock <jamie@jamiebullock.com>2014-06-05 20:31:06 +0100
commitd4c054abb709b3e4bbfa383209996e07d37e84c3 (patch)
treeeff97a98adb1e74f3aa261c2dde2202943ff1a39 /src/stateful.c
parent1691427529bbe02155b47b2c36b4b5ea8fb0bc87 (diff)
downloadLibXtract-d4c054abb709b3e4bbfa383209996e07d37e84c3.tar.gz
LibXtract-d4c054abb709b3e4bbfa383209996e07d37e84c3.tar.bz2
LibXtract-d4c054abb709b3e4bbfa383209996e07d37e84c3.zip
Fix bug in xtract_last_n()
Diffstat (limited to 'src/stateful.c')
-rw-r--r--src/stateful.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/stateful.c b/src/stateful.c
index 501db45..0b607bc 100644
--- a/src/stateful.c
+++ b/src/stateful.c
@@ -50,7 +50,7 @@ xtract_last_n_state *xtract_last_n_state_new(size_t N)
last_n_state->ringbuf = ringbuf_new(N * sizeof(double));
- if (last_n_state->ringbuf)
+ if (last_n_state->ringbuf == NULL)
{
perror("could not allocate memory for xtract_last_n_state->ringbuf");
}
@@ -66,7 +66,6 @@ void xtract_last_n_state_delete(xtract_last_n_state *last_n_state)
int xtract_last_n(const xtract_last_n_state *state, const double *data, const int N, const void *argv, double *result)
{
- double *current = (double *)argv;
size_t N_bytes = N * sizeof(double);
if (N_bytes != ringbuf_capacity(state->ringbuf))
@@ -75,7 +74,7 @@ int xtract_last_n(const xtract_last_n_state *state, const double *data, const in
return XTRACT_BAD_STATE;
}
- ringbuf_memcpy_into(state->ringbuf, current, sizeof(double));
+ ringbuf_memcpy_into(state->ringbuf, data, sizeof(double));
size_t used = ringbuf_bytes_used(state->ringbuf);
ringbuf_memcpy_from(result, state->ringbuf, used, false);