Add missing malloc.h include - #131
Conversation
|
So apparently I'm going to back away slowly and let someone else handle this... |
lol yea it does seem messy but it kinda makes sense since alloca isnt standardized at all. at least the unixy systems have it bundled with stdlib.h. this resolves my confusion as to why you got that compile error before and i didnt (because i assume you are on windows and im on linux). i guess its fine for it to be messy since it shouldnt be used for platform independent code anyway, and im not too sure why its used here but if it must be kept then maybe a simple preprocessor branch for if the platform os is windows or macos or linux to include the correct libraries? the best solution would be to remove calls to alloca entirely though |
|
That's pretty unfortunate for such a basic and useful function. I understand it requires compiler-specific implementation, but no standardization at all is rough. I use the equivalent in C# all the dang time, and plenty in C as well (on the odd occasion I find myself writing C). I'm guessing an |
|
ok so ive looked at all the call sites of alloca and it seems like most of the times its using alloca to avoid being dependent on malloc. i think maybe there could be a toggleable USE_MALLOC macro then switch out calls to alloca and malloc (and free) accordingly. the other calls to alloca (the ones that werent used to avoid the reliance on malloc) they can be replaced by normal c array declaration syntax |
ah i didnt see your reply before sending my reply sorry lol. but yea im with you |
CNFGOGL.cusesallocaon line 235, however does not importmalloc.h, where that is defined. This causes issues in downstream applications like colorchord, where it surfaces as a call to an undeclared function. This PR just adds the missing include.