History

trying out leaf setting to determine whether to clear memory on allocation

Matthew Wang committed 6 years ago

Commit 44000f71 parent 28287233 files · +10 −1Browse files

Unified · Split

3 files
  1. LEAF/Inc/leaf-global.h +2 −1
  2. LEAF/Src/leaf-mempool.c +6 −0
  3. LEAF/Src/leaf.c +2 −0
LEAF/Inc/leaf-global.h+2−1
@@ -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.
LEAF/Src/leaf-mempool.c+6−0
@@ -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}
LEAF/Src/leaf.c+2−0
@@ -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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t