malloc vs calloc Differences Explained | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Great video; the thing I find amazing is that even though using calloc() is at a drop in performance over the re assignment of one million integers; it still only took 1.6 thousandths of a second to do it which is still staggeringly quick and a testament as to how fast modern machines have actually become.

towtruckn
Автор

Thank you for explaining with example codes which majority of the channels don't do

sshrek
Автор

This was an amazing explanation, way better than my prof thank you!

goranosvald
Автор

Wow! An amazing explanation indeed! Thanks a lot!

aadhuu
Автор

hello sir as the first comment on this video first of all i wanted to thank u because of this tutorial .no matter how few your views are keep sharing videos like this 😊

atamovassagi
Автор

1+ sub. Great explanation and good example to deliver the concept

federicobau
Автор

Great video. I think I should need calloc when creating buffer to pass to Windows api functions, right ?

kcvinu
Автор

first thank for the videos I am learning a lot through them! I did tried the clock part for this example and not sure why but I am getting in many runs a faster time for the calloc allocation. Any idea what might be going on? I am using gcc in an ubuntu os.

vicsteiner
Автор

a two year old video saved me. WOW great vid 👍🏾

nikhilsha
Автор

Great video! While I get the concept of what you are doing here. I am a little confused on the "when" to use it. I mean, couldn't data always be there when using malloc? If so, wouldn't that always be a problem?

PremiereStoss-qmun
Автор

hello you said you free the junk but then how come you fill up the heap with junk data ? I really didnt get that...

cnbtwky
Автор

I have always been confused about calloc. I wonder if calloc implementation is a bit more than just doing a malloc of ‘number * size’ then a ´memset’. That was my implementation for my computer science project lol

vsantet
Автор

Is the combination of malloc and memset better than calloc?

theyayaa
Автор

please explain (toc-tic)/CLOCKS_PER_SEC
what is this divider is and why it needed?

shadowrealm
Автор

hey i followed this tutorial, but in the tictoc example I always get both malloc and calloc. I had to increase the memory allocation for 1 trillion integer in order for it to show the time duration.

but even so, the difference between malloc vs calloc in my laptop is 0.006s vs 0.005s.

Has there been a major C release that made calloc as fast as malloc?

pietraderdetective
Автор

First of all, amazing video. Also what IDE are you using or is it even an IDE? I’m new to coding so sorry for the dumb question.

sleepysafron
Автор

Great video and explanation! I am binge watching all your videos!! One thing though, what is the downside to using mallac? I know you explain that data can be there but how does that interact with your code?

ChrisNoesen
Автор

I'm trying to run the code at 4:26 in linux (fedora) and the terminal outputs to me:

malloc(): corrupted top size
Aborted (core dumped)

(Edit) If I run it again, I get other messages before Aborted, that are:

double free or corruption (!prev)
free(): invalid next size (normal)

someonespecial
Автор

Nice. Where did you learn to explain things so easily and efficiently?

FacundoTroitero
Автор

Is there another memory allocation function that allows a specified value to be assigned to each memory address, i.e., a variant of calloc?

Also, do calloc and malloc work on doubles, longs, structure, etc.

Mnogojazyk