Unified · Split
| @@ -20,8 +20,9 @@ extern "C" { · 19 unmodified lines | |||
| 20 | float sampleRate; | 20 | float sampleRate; |
| 21 | float invSampleRate; | 21 | float invSampleRate; |
| 22 | int blockSize; | 22 | int blockSize; |
| 23 | float twoPiTimesInvSampleRate; | 23 | float twoPiTimesInvSampleRate; |
| 24 | float (*random)(void); | 24 | float (*random)(void); |
| 25 | int clearOnAllocation; | ||
| 25 | } LEAF; | 26 | } LEAF; |
| 26 | 27 | ||
| 27 | extern LEAF leaf; // The global instance of LEAF. | 28 | extern LEAF leaf; // The global instance of LEAF. |
| @@ -141,6 +141,12 @@ void* mpool_alloc(size_t asize, mpool_t* pool) · 140 unmodified lines | |||
| 141 | 141 | ||
| 142 | pool->usize += header_size + node_to_alloc->size; | 142 | pool->usize += header_size + node_to_alloc->size; |
| 143 | 143 | ||
| 144 | if (leaf.clearOnAllocation > 0) | ||
| 145 | { | ||
| 146 | char* new_pool = (char*)node_to_alloc->pool; | ||
| 147 | for (int i = 0; i < node_to_alloc->size; i++) new_pool[i] = 0; | ||
| 148 | } | ||
| 149 | |||
| 144 | // Return the pool of the allocated node; | 150 | // Return the pool of the allocated node; |
| 145 | return node_to_alloc->pool; | 151 | return node_to_alloc->pool; |
| 146 | } | 152 | } |
| @@ -34,6 +34,8 @@ void LEAF_init(float sr, int blocksize, char* memory, size_t memorysize, float(* · 33 unmodified lines | |||
| 34 | leaf.twoPiTimesInvSampleRate = leaf.invSampleRate * TWO_PI; | 34 | leaf.twoPiTimesInvSampleRate = leaf.invSampleRate * TWO_PI; |
| 35 | 35 | ||
| 36 | leaf.random = random; | 36 | leaf.random = random; |
| 37 | |||
| 38 | leaf.clearOnAllocation = 0; | ||
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | 41 | ||