-
-
Notifications
You must be signed in to change notification settings - Fork 123
introduce psram-aware malloc functions (backport of upstream #4895) #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
15b6907
c6a4e28
d273835
a861a31
b78d5e6
e714ede
98c9788
31e56ae
4c93146
9408564
735047f
78a964c
62e4cab
1eaad1b
60f8648
67c70a2
68dbd5e
69946e4
381ad56
2d71ab3
b62b40b
ffe718b
66847a3
ccc96af
26a4abe
6f99aa0
75cbe6c
3b29475
8a2ecf3
cbcdf6d
3c1d8b4
ba715a4
db8f928
bb7f0ec
2508bff
5b1b689
3babb52
81de35f
5f03cf9
336bce5
eacb663
9a30d9e
f9347ff
c352f2a
ab7b2c8
2137434
a65cb40
2fd71e8
1dce8d7
6251120
8917e6d
6aa054b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2562,14 +2562,24 @@ class ARTI { | |||||||||||||
|
|
||||||||||||||
| //open programFile | ||||||||||||||
| char * programText = nullptr; | ||||||||||||||
| uint16_t programFileSize; | ||||||||||||||
| size_t programFileSize; | ||||||||||||||
| #if ARTI_PLATFORM == ARTI_ARDUINO | ||||||||||||||
| programFileSize = programFile.size(); | ||||||||||||||
| programText = (char *)malloc(programFileSize+1); | ||||||||||||||
| programText = (char *)d_malloc(programFileSize+1); | ||||||||||||||
| if (programText == nullptr) { | ||||||||||||||
| ERROR_ARTI("ARTI-FX: Failed to allocate memory for program file (%u bytes)\n", programFileSize+1); | ||||||||||||||
| programFile.close(); | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
| programFile.read((byte *)programText, programFileSize); | ||||||||||||||
| programText[programFileSize] = '\0'; | ||||||||||||||
| #else | ||||||||||||||
| programText = (char *)malloc(programTextSize); | ||||||||||||||
| programText = (char *)malloc(programTextSize+1); | ||||||||||||||
| if (programText == nullptr) { | ||||||||||||||
| ERROR_ARTI("ARTI-FX: Failed to allocate memory for program file (%u bytes)\n", programTextSize); | ||||||||||||||
| programFile.close(); | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
| programFile.read(programText, programTextSize); | ||||||||||||||
| DEBUG_ARTI("programFile size %lu bytes\n", programFile.gcount()); | ||||||||||||||
| programText[programFile.gcount()] = '\0'; | ||||||||||||||
|
|
@@ -2607,7 +2617,13 @@ class ARTI { | |||||||||||||
| #endif | ||||||||||||||
|
|
||||||||||||||
| if (stages < 1) { | ||||||||||||||
| if (nullptr != programText) free(programText); // softhack007 prevent memory leak | ||||||||||||||
| // softhack007 prevent memory leak | ||||||||||||||
| #if ARTI_PLATFORM == ARTI_ARDUINO | ||||||||||||||
| if (nullptr != programText) d_free(programText); | ||||||||||||||
| #else | ||||||||||||||
| if (nullptr != programText) free(programText); | ||||||||||||||
| #endif | ||||||||||||||
| programText = nullptr; | ||||||||||||||
| close(); | ||||||||||||||
| return true; | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
2619
to
2629
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The first The genuine concern is 💡 Clarification — the dead guard vs. the real leak
🤖 Prompt for AI Agents |
||||||||||||||
|
|
@@ -2666,8 +2682,11 @@ class ARTI { | |||||||||||||
| #endif | ||||||||||||||
| } | ||||||||||||||
| #if ARTI_PLATFORM == ARTI_ARDUINO //not on windows as cause crash??? | ||||||||||||||
| d_free(programText); | ||||||||||||||
| #else | ||||||||||||||
| free(programText); | ||||||||||||||
| #endif | ||||||||||||||
| programText = nullptr; | ||||||||||||||
|
|
||||||||||||||
| if (stages >= 3) | ||||||||||||||
| { | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.