Sjmarf@sh.itjust.works to Programming Horror@programming.dev · 2 months agomallocPlusAIsh.itjust.worksimagemessage-square31fedilinkarrow-up1239arrow-down12
arrow-up1237arrow-down1imagemallocPlusAIsh.itjust.worksSjmarf@sh.itjust.works to Programming Horror@programming.dev · 2 months agomessage-square31fedilink
minus-squarezaphod@sopuli.xyzlinkfedilinkarrow-up14arrow-down1·2 months agoYou don’t need to cast the return value from malloc.
minus-squareaddie@feddit.uklinkfedilinkarrow-up10arrow-down1·2 months 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.
minus-squareembed_me@programming.devlinkfedilinkarrow-up3·2 months agoVoid pointer should be avoid anyways. Even I find them rare and I mostly work in embedded RTOS
minus-squareSubverb@lemmy.worldlinkfedilinkarrow-up6·edit-22 months 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.
minus-squarevrighter@discuss.tchncs.delinkfedilinkarrow-up1·2 months 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::any
all the more.Void pointer should be avoid 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++