Hi All,

i am using a malloc to allocate some memory in my project and also defining the stack and heap size for the program to use while running.

I am facing a weird problem which is like at certain point when i am trying to malloc and allocate some memory it fails and gives a segmentation violation error and terminates the program. I tried replacing the same with calloc and the program runs fine with no issues at all.

as far as my knowledge base says its like the malloc and calloc both does the same thing of allocating the memory while calloc only initializes the memory to zero and aloocates the memory in blocks whereas malloc allocates in bytes.

so i tried teh malloc and then memset the memory to initialize it to zero but that again crashes the program at malloc again. I cant understand the problem and how to rectify it.

can anyone send some piece of information or some tutorial / article so that i can be able to undertand the logic and why it is happening??

any help or pointers are highly appreciated.

thanks a lot in advance.

Best Regards,
Himanshu Singh