[Insight-developers] NIFTI : malloc() vs "new"

kent williams norman-k-williams at uiowa.edu
Wed Jan 23 09:56:01 EST 2008


NiftiImageIO::Read -- malloc is used because niftilib will eventually free
the buffer. Niftilib is a straight C library.

NiftiImageIO::WriteImageInformation -- same reason for using malloc.

In both those cases, the issue is that the code I wrote is directly setting
fields in the nifti image data structure, and then using the niftilib
function provided to release that structure.

It might be possible to force the nifti library to handle it's own
allocation in these cases.  When I wrote itk::NiftiImageIO I didn't take the
time to determine if this was possible.

On 1/22/08 6:36 PM, "Luis Ibanez" <luis.ibanez at kitware.com> wrote:

> 
> We are cleaning a large set of warning related to conversions between
> 64bits and 32bits integers, and in the process we run across a group
> of memory allocations being made in the NiftiImageIO class.
> 
> We are wondering why this class is mixing memory allocations with
> "malloc()" in some places and with "new" in some places.
> 
> Our suggestion will be to convert all memory allocations to "new",
> and accordingly replace calls to free() with the use of the "delete"
> operator.
> 
> 
> Could someone from the NIFTI community provide some guidance ?
> 
> 
>     Thanks
> 
> 
>       Luis
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list