Sjmarf@sh.itjust.works to Programming Horror · 1 year agomallocPlusAIsh.itjust.worksCodestin Search AppCodestin Search App31Codestin Search AppCodestin Search AppCodestin Search App262Codestin Search App2
Codestin Search App260Codestin Search AppCodestin Search AppmallocPlusAIsh.itjust.worksSjmarf@sh.itjust.works to Programming Horror · 1 year agoCodestin Search App31Codestin Search AppCodestin Search App
Codestin Search Appzaphod@sopuli.xyzCodestin Search AppCodestin Search AppCodestin Search App14Codestin Search App1·1 year agoYou don’t need to cast the return value from malloc.
Codestin Search Appaddie@feddit.ukCodestin Search AppCodestin Search AppCodestin Search App11Codestin Search App1·1 year agoTrue. Although given how easy it is to cast void pointers to the wrong damn thing, it would be nice if you did, makes refactoring much easier. Makes me appreciate std::any all the more.
Codestin Search Appembed_meCodestin Search AppCodestin Search AppCodestin Search App3·1 year agoVoid pointer should be avoided anyways. Even I find them rare and I mostly work in embedded RTOS
Codestin Search AppSubverb@lemmy.worldCodestin Search AppCodestin Search AppCodestin Search App6·1 year agoThis isn’t malloc though. I have to assume the cast is because the user has experience with the output from an LLM being untrustworthy.
Codestin Search Appvrighter@discuss.tchncs.deCodestin Search AppCodestin Search AppCodestin Search App2·1 year agoyou do in c++, no?
Codestin Search Appzaphod@sopuli.xyzCodestin Search AppCodestin Search AppCodestin Search App2·1 year agoIn c++ you should use new.
Codestin Search Appvrighter@discuss.tchncs.deCodestin Search AppCodestin Search AppCodestin Search App1·1 year agothat is besides the point. You can still call malloc, it will still return void*, and it would still reqoire casting in c++
You don’t need to cast the return value from malloc.
True. Although given how easy it is to cast void pointers to the wrong damn thing, it would be nice if you did, makes refactoring much easier. Makes me appreciate
std::anyall the more.Void pointer should be avoided anyways. Even I find them rare and I mostly work in embedded RTOS
This isn’t malloc though. I have to assume the cast is because the user has experience with the output from an LLM being untrustworthy.
you do in c++, no?
In c++ you should use
new.that is besides the point. You can still call malloc, it will still return void*, and it would still reqoire casting in c++