strlcat / smalloc

SMalloc -- a *static* memory allocator.
MIT License
36 stars 12 forks source link

Arduino, Teensy #1

Open luni64 opened 4 years ago

luni64 commented 4 years ago

I tried your smalloc in an embedded environment (PJRC Teensy) which so far works perfectly. Ultimately I want to use it to access an externally attached memory chip which I'm sure will work as well.

To make your code more accessible to the average Arduino user I'd like to wrap it in an Arduino style library. Basically this just means to place the code in certain subfolders and add a header taking care of the required extern "C" to use it under c++.

Additionally I'd add some easy to understand examples to the repository. I saw that your code is under MIT but thought it might be polite to ask anyway if this is OK with you.

(Credits of course goes to you and I'd link back to your repository)

luni64 commented 4 years ago

I meanwhile have set up a repo with the changes as mentioned above https://github.com/luni64/static_malloc Since I really don't like to adorn myself with borrowed plumes, I can also transfer the ownership of my wrapper library to you if you prefer.

strlcat commented 3 years ago

Hi,

for some reason, github did not sent email notification the time you submitted the issue, apologise for that

While I do agree that code may require additional revisions to make it C++ friendly, the directory structure shall remain as it is presented here, because it's a typical unix style thing.

Otherwise you can do whatever you want with the code, and forking away (ofc with keeping these minimal origin notes MIT license requires), modifying etc. what MIT permits you to do is encouraged. So, feel free to do that :)

It's not clear to me what exactly changes are required here aside of making header more C++ friendly. And I don't think transferring ownership is required. What's your plan?

luni64 commented 3 years ago

Hi Andrey,

Thanks for your answer.

While I do agree that code may require additional revisions to make it C++ friendly, the directory structure shall remain as it is presented here, because it's a typical unix style thing.

Sure, I don't suggest to change anything in your repo, it just works fine as it is.

My use case is the Arduino ecosystem. Specifically the PJRC Teensy 4.1 boards, which have an optional, external RAM chip. Smalloc is perfect to access this RAM. However, to make it more accessible to the average Arduino hobby user, I re-arranged your files, added a c++ compatible header , and some examples. (See https://github.com/luni64/static_malloc)

Here a link to a Teensy forum thread which discusses the use of your library for Teensies: https://forum.pjrc.com/threads/63695-malloc-free-for-EXTMEM-and-DTCM.

strlcat commented 3 years ago

I see. I briefly listed through pages on thread you mentioned. Had you any troubles you ran into while using the thing? As you might noticed, it's not quite performant compared to "traditional" allocators & was developed primarily for secure small programs & debugging allocation problems.