Results 1 to 4 of 4

Thread: What is the use of malloc and calloc functions

  1. #1
    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.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    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.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    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

  4. #4
    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.

Similar Threads

  1. Need SQL plus commands and functions
    By Barsha in forum Software Development
    Replies: 4
    Last Post: 25-02-2010, 06:19 AM
  2. Difference between new and malloc.
    By Bansi_WADIA in forum Software Development
    Replies: 3
    Last Post: 01-12-2009, 05:25 PM
  3. How to call a C functions within PHP?
    By Rixwel in forum Software Development
    Replies: 3
    Last Post: 05-09-2009, 09:12 AM
  4. Malloc which covers an area allocated to the compilation
    By Kirt in forum Software Development
    Replies: 4
    Last Post: 10-04-2009, 12:04 AM
  5. Functions in PHP
    By Gyan Guru in forum Guides & Tutorials
    Replies: 3
    Last Post: 13-12-2008, 06:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,890,810.26686 seconds with 16 queries