What is diff b/w malloc,calloc,r ealloc
could any one explain 6 10689
malloc returns uninitialized memory, calloc initializes the memory to
all bits zero, and realloc is way more flexible than it should be.
realloc can act like malloc or free, or it can resize memory returned
by malloc, calloc, or a previous realloc call, possibly allocating a
new block and invalidating any pointers into the memory. no*@given.out wrote: On Wed, 23 Mar 2005 14:41:10 +0100, "Ramasubramania n XR (AS/EAB)" <ra************ **************@ ericsson.com> wrote:
What is diff b/w malloc,calloc,r ealloc could any one explain
Pointer = calloc(NumBlock s, BlockSize) ... Clears and allocates the given number of blocks of a given size. (most useful for arrays)
Be careful, though: "clears" means "fills with 0-valued bytes", not
necessarily "fills with zero values". In particular, 0x00000000 need not
be the representation of a zero-valued floating point number or of a
null pointer.
Richard
"Ramasubramania n XR (AS/EAB)" wrote: What is diff b/w malloc,calloc,r ealloc could any one explain
See the last two references below.
--
Some useful references:
<http://www.ungerhu.com/jxh/clc.welcome.txt >
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware. com/refxc.html> C-library
Ramasubramanian XR (AS/EAB) wrote: What is diff b/w malloc,calloc,r ealloc could any one explain
What book are you using that doesn't cover such fundamental memory
management functions?
Brian
Ramasubramanian XR (AS/EAB) wrote on 23/03/05 : What is diff b/w malloc,calloc,r ealloc could any one explain
It's all explained in any decent C book or help file.
google : "man malloc" "man realloc" "man calloc"
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
"what is a local variable?"
Ramasubramanian XR (AS/EAB) wrote: What is diff b/w malloc,calloc,r ealloc could any one explain
Why don't you read the manual or man pages like the rest of us did? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kumar |
last post by:
Hi,
Can somebody advise me on what is the best alternative for realloc in C++?
Is it safe to "realloc"ate memory allocated using new operator ?
|
by: Harsimran |
last post by:
Can any one explain what are far pointers and what is the difference
between malloc and calloc .Which is better ?
|
by: ala |
last post by:
I have something near to this:
unsigned *p, *a;
p = malloc(80*sizeof(unsigned));
a=p;
if(p==0) exit(1);
<code snip>
/******************/
free(p);
/******************/
|
by: Lawrie |
last post by:
Hi,
I am fairly new to C programming and would like to ask a little help
with the following problem.
I am writing a simple ring buffer, implemented as an array of char *.
char* ringbuffer;
When I receive a new message (of type char*) I need to make a copy of
|
by: Jerry |
last post by:
Hi,all
I write a function to copy one memory buffer to anther with
dynamic allocationg when the destination is not large enough.
The code is below:
void DSM_CC::fillBuf(unsigned char** pdstBuf,int* pdstBufBase,int*
pdstTolalLen,char* pbufToWrite,int lenToWrite)
{
unsigned char* tmp;
int step = 256;
| |
by: ramu |
last post by:
Hi,
Will the memory allocated by malloc and realloc be contiguous?
regards
|
by: quiberon2 |
last post by:
Hi,
Sorry if it might be a stupid question but what should returns
malloc(0) ?
void *ptr = malloc(0);
I am running gcc 3.3.5 and a non-null address is returned.
( in the compiler that I am currently implementing, NULL is returned.
Is it wrong ?)
|
by: Raman |
last post by:
Hi All,
As per my understanding, malloc and calloc differs in the way they
allocate memory( malloc give a contigous block, But calloc may give
Non-contigous block as well).
Now consider this program.
int main()
{
char *p;
|
by: rasmidas |
last post by:
I have a function,
int dmgDocExplodeInception
(
sENTITY* Entity,
sDOC_SOURCE* DocSource,
sUINT Mode
)
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |