MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w2m4qz/bugintroduceddebugging/p6tqmfp/?context=9999
r/ProgrammerHumor • u/ClipboardCopyPaste • 2d ago
120 comments sorted by
View all comments
0
I'm not good enough at programming for this. What do the "free" and "malloc" functions do?
26 u/LucyShortForLucas 2d ago They are core C functions. malloc allocates N bytes of memory, free frees that memory. * is t he dereference operator, so *x is trying to dereference freed memory, which is undefined behavior 3 u/DiodeInc 2d ago I thought * was a pointer. Isn't it? How is it dereferencing freed memory? Or is it because it's returning *x that's the bug? 8 u/Vimda 2d ago * in a variable declaration incidates a pointer type, * in a statement is the dereference operator 2 u/DiodeInc 2d ago I see. Thanks
26
They are core C functions. malloc allocates N bytes of memory, free frees that memory. * is t he dereference operator, so *x is trying to dereference freed memory, which is undefined behavior
3 u/DiodeInc 2d ago I thought * was a pointer. Isn't it? How is it dereferencing freed memory? Or is it because it's returning *x that's the bug? 8 u/Vimda 2d ago * in a variable declaration incidates a pointer type, * in a statement is the dereference operator 2 u/DiodeInc 2d ago I see. Thanks
3
I thought * was a pointer. Isn't it? How is it dereferencing freed memory?
Or is it because it's returning *x that's the bug?
8 u/Vimda 2d ago * in a variable declaration incidates a pointer type, * in a statement is the dereference operator 2 u/DiodeInc 2d ago I see. Thanks
8
* in a variable declaration incidates a pointer type, * in a statement is the dereference operator
2 u/DiodeInc 2d ago I see. Thanks
2
I see. Thanks
0
u/LostgamerFJ 2d ago
I'm not good enough at programming for this. What do the "free" and "malloc" functions do?