linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mehran Rezaei" <mehran@cs.unt.edu>
To: "Earl R. Lapus" <elapus@ntsp.nec.co.jp>,
	linux-c-prog <linux-c-programming@vger.kernel.org>
Subject: Re: malloc
Date: Mon, 17 Jun 2002 11:47:03 -0500	[thread overview]
Message-ID: <001601c2161e$9b937f40$da247881@ali> (raw)
In-Reply-To: LFEIJFMKHCJIHBFOGINPCEPJCBAA.elapus@ntsp.nec.co.jp


> hi,
>    I tried doing this:
>        ucp = (unsigned char *) malloc(0);
>    it was successful and returned a valid address. I was kinda hoping
>    it would do something weird...When I looked at the man page It said
>    something like.. "If your application needs to generate empty objects,
>    you may use malloc(0) for this purpose..."
>
>    So my questions are:
>        What do you mean when you say EMPTY OBJECT?
>        Does it ocuppy any memory storage?
Hi there,
Of course it depends on the implementation. However, since Doug Lea'
allocator is the base and everybody else follows his setup here I am writing
about his allocator:
malloc(size_t n)
if "n" is zero, malloc returns a minimum-sized chunk (the minimum size is 16
bytes on most 32 bit machines, and 24 or 32 bytes on 64 bit machines).
From 16 bytes or 32 bytes returned, you do not see the header (2*address
size of machine - 64 bits in case of 32 bit machine). It leaves you 8 bytes
to use.
I believe gnu uses Doug Lea' allocator.
So long,

Mehran


  parent reply	other threads:[~2002-06-17 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17 21:26 malloc Earl R. Lapus
2002-06-17 13:48 ` malloc Glynn Clements
2002-06-17 14:32 ` malloc Jason P. Winters
2002-06-17 16:47 ` Mehran Rezaei [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-12-20  4:39 malloc ratheesh k
2010-12-20  4:43 ` malloc Santosh Sivaraj
2010-12-27 18:51 ` malloc Uriel Corfa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001601c2161e$9b937f40$da247881@ali' \
    --to=mehran@cs.unt.edu \
    --cc=elapus@ntsp.nec.co.jp \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).