ref: 20bdada1161b9065829a209cd9b3858e55c7cbd7
parent: 1fdec38ec4c2fe00804f80c23583fb1f14728f78
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-9-128-35.princeton.edu>
date: Tue Nov 19 10:34:28 EST 2019
mempool linked list implementation
binary files a/.DS_Store b/.DS_Store differ
--- a/LEAF/Src/leaf-effects.c
+++ b/LEAF/Src/leaf-effects.c
@@ -46,9 +46,11 @@
{
leaf_free(v->car0);
leaf_free(v->car1);
- leaf_free(v->window);
+
leaf_free(v->buf0);
leaf_free(v->buf1);
+
+ leaf_free(v->window);
}
void tTalkbox_update(tTalkbox* const v) ///update internal parameters...
@@ -851,6 +853,7 @@
void tSOLAD_free(tSOLAD* const w)
{
+ leaf_free(w->delaybuf);
}
// send one block of input samples, receive one block of output samples
--- a/LEAF/Src/leaf-mempool.c
+++ b/LEAF/Src/leaf-mempool.c
@@ -107,8 +107,7 @@
node_to_alloc->size = size_to_alloc;
if (leftover > header_size)
{
- long offset = node_to_alloc - (mpool_node_t*) pool->mpool;
- offset *= sizeof(mpool_node_t);
+ long offset = (char*) node_to_alloc - (char*) pool->mpool;
offset += header_size + node_to_alloc->size;
new_node = create_node(&pool->mpool[offset],
node_to_alloc->next,
@@ -168,28 +167,42 @@
{
// Increase freed node's size
freed_node->size += header_size + other_node->size;
- // Delink the merged node
+ // If we are merging with the head, move the head forward
+ if (other_node == pool->head) pool->head = pool->head->next;
+ // Delink the merged node (Shouldn't really be necessary since we're formatting)
delink_node(other_node);
- // Attach the merging node to the head
- freed_node->next = pool->head;
}
+
// Check if a node is directly before the freed node
else if ((long) other_node + (header_size + other_node->size) == (long) freed_node)
{
// Increase the merging node's size
other_node->size += header_size + freed_node->size;
- // Delink the merging node
- delink_node(other_node);
- // Attach the merging node to the head
- other_node->next = pool->head;
- // Nodes are merged
- freed_node = other_node;
+
+ if (other_node != pool->head)
+ {
+ // Delink the merging node
+ delink_node(other_node);
+ // Attach the merging node to the head
+ other_node->next = pool->head;
+ // Merge
+ freed_node = other_node;
+ }
+ else
+ {
+ // If we are merging with the head, move the head forward
+ pool->head = pool->head->next;
+ // Merge
+ freed_node = other_node;
+ }
}
other_node = next_node;
}
- // Do this after any merging
+ // Ensure the freed node is attached to the head
+ freed_node->next = pool->head;
+ if (pool->head != NULL) pool->head->prev = freed_node;
pool->head = freed_node;
// Format the freed pool
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -21,6 +21,7 @@
tDelay delay;
tRetune retune;
tAutotune autotune;
+tTalkbox test;
float gain;
float freq;
@@ -39,10 +40,22 @@
tCycle_init(&sine);
tCycle_setFreq(&sine, 200);
tDelay_init(&delay, 44100, 44100);
- tDelay_free(&delay); //most basic free test
+ tDelay_free(&delay);
tDelay_init(&delay, 44100, 44100);
+ tTalkbox_init(&test, 1024);
+ tTalkbox_free(&test);
+ tTalkbox_init(&test, 1024);
+
tRetune_init(&retune, 1, 2048, 1024);
+
+ tDelay_free(&delay);
+ tRetune_free(&retune);
+ tTalkbox_free(&test);
+ tTalkbox_init(&test, 1024);
+ tDelay_init(&delay, 44100, 44100);
+ tRetune_init(&retune, 1, 2048, 1024);
+
tAutotune_init(&autotune, 8, 2048, 1024);
}