Mercurial > hg > libxtract
changeset 242:d2453f55c470
Fix bug in xtract_last_n()
author | Jamie Bullock <jamie@jamiebullock.com> |
---|---|
date | Thu, 05 Jun 2014 20:31:06 +0100 |
parents | 66ebf1399a29 |
children | d13189c1005c |
files | src/stateful.c |
diffstat | 1 files changed, 2 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/stateful.c Thu Jun 05 20:30:08 2014 +0100 +++ b/src/stateful.c Thu Jun 05 20:31:06 2014 +0100 @@ -50,7 +50,7 @@ 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 @@ 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 @@ 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);