[Python-Dev] Problem with the memory docs

Martin v. Loewis martin@v.loewis.de
05 Apr 2002 20:21:19 +0200


Guido van Rossum <guido@python.org> writes:

> I'm still confused.  What is the difference between calling malloc(1)
> and returning a non-null pointer "normally" ?

There is probably no practical difference. If you do malloc(0) and get
a non-zero pointer, you cannot access any memory behind this pointer;
if you invoke malloc(1), the C library must make sure that there is
atleast a single byte to access. This may take larger efforts - but
probably doesn't, in practice (unless your malloc implementation tries
to clear the memory it allocates with a fence pattern).

Regards,
Martin