embeddedartistry / libc

libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
MIT License
520 stars 67 forks source link

Doxygen Documentation: string.h #27 #34

Closed seekaddo closed 6 years ago

seekaddo commented 6 years ago

Doxygen documentation for the functions in string.h. I have already tested it.

PN: I added errno setting for some of the functions, like strdup when an error occurs. We don't have malloc implemented yet and also errno. I added it for feature. We can also remove it for now to prevent confusion and later make a new PR for the new changes in those methods.

errno and malloc.

The strdup function makes a call to malloc in its implementation. I was wondering which malloc is that then since can't use the normal libc malloc for Embedded. Can we implement a simple wrapper malloc for this? With just a simple ringbuffer to a static array.

All kinds of Feedback and suggestions are welcome.

phillipjohnston commented 6 years ago

Regarding malloc: It's actually implemented in libmemory. Malloc implementations are very situation-dependent and can vary widely depending on whether you're using a PC, bare metal firmware, or an RTOS. I have kept malloc separate to account for that fact. I think the documentation for malloc should still be included here because it is technically a libc function.

I will eventually make it a submodule, but I have not yet architected a good way to include it in the build system. I'll be thinking more about that in the coming weeks.

Regarding errno: Leaving the notes in is fine, as I do plan on adding support (#6)

Thanks again for your great help!

seekaddo commented 6 years ago

@phillipjohnston oh ok. Then everything will be great. Thanks for the explanation. Yea with the errno I was thinking about how to implement it to support both sterrorr() and others. I was thinking of using enum for defining all the type errno's EINVAL ... etc. and a static string array enum {EINVAL,....} errn; extern errn errno;

static const char *const MALLOC = {"Each malloc interpretation in strings"} 

Something like this I have in mind.