C in 100 Seconds
Video Statistics and Information
Channel: Fireship
Views: 396,571
Rating: 4.9661527 out of 5
Keywords: webdev, app development, lesson, tutorial
Id: U3aXWizDbQ4
Channel Id: undefined
Length: 2min 25sec (145 seconds)
Published: Wed Nov 10 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
This is a pretty bad guide.
"You can store that [memory] address in another variable called a pointer. When the variable is no longer needed, you'll need to free it to avoid a memory leak"
This is very confused. The function
free
is a standard library function which frees a block of memory allocated viamalloc
/calloc
/realloc
, etc. The allocation functions give you a pointer, andfree
takes a pointer, but that's where the connection ends. There's nothing whatsoever in the notion of a pointer itself that requires you to callfree
to avoid a memory leak. You can of course have multiple pointers to the same memory; for instance, you might use a pointer to iterate over elements (and you wouldn't want to call free on the pointer when you were finished with the iterator!) which could be allocated on the heap or on the stack.It's also quite amusing that the author's example compilation causes a seg-fault when run.
Note: I am not the author of this video.