History

add error case to mpool_free

Matthew Wang committed 6 years ago

Commit 17acc7e1 parent 1bf02963 files · +10 −2Browse files

Unified · Split

3 files
  1. leaf/Src/leaf-mempool.c +6 −0
  2. leaf/Src/leaf.c +2 −1
  3. leaf/leaf.h +2 −1
leaf/Src/leaf-mempool.c+6−0
@@ -261,6 +261,12 @@ void mpool_free(char* ptr, _tMempool* pool) · 260 unmodified lines
261 mpool_node_t* next_node;261 mpool_node_t* next_node;
262 while (other_node != NULL)262 while (other_node != NULL)
263 {263 {
264 if ((char*)other_node < (char*)pool->head ||
265 (char*)other_node >= ((char*)pool->head + pool->msize))
266 {
267 LEAF_error(2);
268 return;
269 }
264 next_node = other_node->next;270 next_node = other_node->next;
265 // Check if a node is directly after the freed node271 // Check if a node is directly after the freed node
266 if ((long) freed_node + (leaf.header_size + freed_node->size) == (long) other_node)272 if ((long) freed_node + (leaf.header_size + freed_node->size) == (long) other_node)
leaf/Src/leaf.c+2−1
@@ -54,7 +54,8 @@ float LEAF_getSampleRate() · 53 unmodified lines
54 54
55 55
56//implement a function called this in your user code to catch errors56//implement a function called this in your user code to catch errors
57__attribute__((weak)) uint8_t LEAF_error(uint8_t whichone)57//__attribute__((weak))
58uint8_t LEAF_error(uint8_t whichone)
58{59{
59 return whichone;60 return whichone;
60}61}
leaf/leaf.h+2−1
@@ -140,7 +140,8 @@ extern "C" { · 139 unmodified lines
140 float LEAF_getSampleRate (void);140 float LEAF_getSampleRate (void);
141 141
142 142
143 __attribute__((weak)) uint8_t LEAF_error(uint8_t whichone);143// __attribute__((weak))
144 uint8_t LEAF_error(uint8_t whichone);
144 145
145 /*!146 /*!
146 * @}147 * @}

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