mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
sample: fix sample_data_remove moving too much memory
Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
parent
365bdd6288
commit
739f8fd0a8
1 changed files with 9 additions and 1 deletions
|
@ -311,7 +311,15 @@ void villas::node::sample_data_insert(struct Sample *smp,
|
|||
|
||||
void villas::node::sample_data_remove(struct Sample *smp, size_t offset,
|
||||
size_t len) {
|
||||
size_t sz = sizeof(smp->data[0]) * len;
|
||||
if (offset + len > smp->length) {
|
||||
if (offset > smp->length) {
|
||||
return;
|
||||
} else {
|
||||
len = smp->length - offset;
|
||||
}
|
||||
}
|
||||
|
||||
size_t sz = sizeof(smp->data[0]) * (smp->length - offset - len);
|
||||
|
||||
memmove(&smp->data[offset], &smp->data[offset + len], sz);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue