> From: Jakob Bohm [mailto:[email protected]]
>
> On 5/25/2012 12:30 AM, Richard Levitte wrote:
> >
> > sudarshan.t.raghavan> I am assuming the default
> > sudarshan.t.raghavan> free routine ignores a NULL argument
> >
> > Your assumption is correct, OpenSSL expects the same semantics as
> > malloc(), realloc() and free(), so you free() replacement must be
> > able to handle a NULL argument.
>
> ANSI C and POSIX free() is NOT required to handle free(NULL)
> as a NOP.
I'm afraid you're wrong on that Jakob. Quoting from C99:
======================================
7.20.3.2 The free function
Synopsis
#include <stdlib.h>
void free(void *ptr);
Description
The free function causes the space pointed to by ptr to be deallocated,
that is, made available for further allocation. If ptr is a null pointer,
no action occurs. Otherwise, if the argument does not match a pointer
earlier returned by the calloc, malloc, or realloc function, or if the
space has been deallocated by a call to free or realloc, the behavior
is undefined.
======================================
The original and current C Standards say the same, as does POSIX.
Regards,
jjf
> ANSI C++ operator delete() is required to do this, but this
> requirement does not extent to free() invoked from a C++ program.
>
> Some libc implementations provide this feature anyway, but it
> is not a required property of free(), and according to Dr.
> Henson's reply above it is not a requirement of the OpenSSL
> custom free() callback either.
>
> Enjoy
>
> Jakob
> --
> Jakob Bohm, CIO, Partner, WiseMo A/S. http://www.wisemo.com
> Transformervej 29, 2730 Herlev, Denmark. Direct +45 31 13 16 10
> This public discussion message is non-binding and may contain errors.
> WiseMo - Remote Service Management for PCs, Phones and Embedded
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]