Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-11-2009
Member
 
Join Date: Jan 2009
Posts: 37
What is the use of malloc and calloc functions

Hi Guys,

I am beginner in the field of programming. I just completed my basic 'C' language. But the concept of the "malloc" and "calloc" functions is still unclear. Even I don't have any idea regarding what is the basic use of the "malloc" and "calloc" functions.

Can you able to help me to clear my doubts regarding "malloc" and "calloc" functions?...

Last edited by Jagadamba : 24-11-2009 at 09:56 AM.
Reply With Quote
  #2  
Old 24-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: What is the use of malloc and calloc functions

"malloc" is a subway for performing allocation of the dynamic memory in the C++ and C languages."malloc" is a important part of the standard library of c & c++ languages. More than one implementations of "malloc" is valid, In which each of them performs entirely different depending on the code of the programming.

Programs should be properly manage dynamic memory which is allocated by the "malloc" function for avoiding any memory corruption and memory leaks.
Reply With Quote
  #3  
Old 24-11-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: What is the use of malloc and calloc functions

Hi,

The malloc and calloc functions are basically the memory allocation functions.
In an application which developed by using the big memory model, the "calloc" & "malloc" functions appear to lose very large memory blocks when the allocation's segment value changes.

For e.g, if an application requests two 32K blocks of memory & the value of segment of the 2nd pointer is entirely different from the value of the segment of 1st pointer,then the variation between the pointers is approx 48,000 bytes.

The "malloc" function is useful to allocate a large memory block from "ms-dos" & continue to allocates memory until it is full
Reply With Quote
  #4  
Old 24-11-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: What is the use of malloc and calloc functions

For your kind information calloc and malloc are the function whch are used in the process of the memory allocation.

But there are some difference between them which are as follows:

1. For calloc we have to pass 2 arguments ,while for malloc it is single.
2.calloc function is useful to allocates block of memory while malloc used to allocate byte of memory.
3.calloc initializes the memory allocated to '0', while malloc does not.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is the use of malloc and calloc functions"
Thread Thread Starter Forum Replies Last Post
Need SQL plus commands and functions Barsha Software Development 4 25-02-2010 06:19 AM
Difference between new and malloc. Bansi_WADIA Software Development 3 01-12-2009 05:25 PM
How to call a C functions within PHP? Rixwel Software Development 3 05-09-2009 09:12 AM
Malloc which covers an area allocated to the compilation Kirt Software Development 4 10-04-2009 12:04 AM
Functions in PHP Gyan Guru Guides & Tutorials 3 13-12-2008 06:20 PM


All times are GMT +5.5. The time now is 03:35 AM.