Efficient coding with strings…

I’m currently creating a modified podzilla 2 build with a few custom functions. The first is loading modules from different locations specified by the passed argments (ie “Podzilla2-Mod /usr/lib/Media /usr/lib/Misc” loads modules from both the “/usr/lib/Media” and “/usr/lib/Misc” folders, and any other ones I may add on). I’ve already got that implemented and fully working. The second one is menu path sorting based on the module’s current folder location. While I have things working nicely at the moment, due to my lack of string manipulation knowledge in C, I’m pretty sure my code at the moment is quite ineffective (memory-wise and probably in other aspects too).

Basically before I load the module, I set the “menupath_mod” variable based on the module’s current folder location (found with pz_module_get_datapath). When “resolve_menupath” is called by any pz_add_* functions, the menupath is modified so that “/Extras/” is replaced by the module’s folder path.

While everything works nicely as I intended, I’m sure my coding can be vastly cleaned up. The numerous strchr’s I used just to get to the third ‘/’ looks really inefficient and I dislike the idea of creating those 128 static chars (though making them non-static just kills memory and freeses PZ2, so don’t have much choice here). I’m not a regular C programmer, so I’m not too familiar with all the functions and how to best use them.