[MINC-users] minc2 api question - miget_volume_dimensions

EJ Nikelski nikelski at bic.mni.mcgill.ca
Wed Aug 5 19:14:55 EDT 2009


Hi Claude (and list),

  Yes. That compiles and runs without a seg fault (always a bonus).
Although I'm a little confused by the fact that when I do a
"printf("Size of:%d.\n", sizeof(midimhandle_t));", I get a size of 4
(the pointer, I suppose).  Should malloc not be allocating enough
space for the entire struct?

  Anyways, nuff work for one day -- I'm off to feed the beagle.

Thanks,

-Jim


On Wed, Aug 5, 2009 at 6:54 PM, Claude LEPAGE<claude at bic.mni.mcgill.ca> wrote:
>> > On Wed, Aug 5, 2009 at 6:29 PM, Claude LEPAGE<claude at bic.mni.mcgill.ca> wrote:
>> >>>
>> >>> midimhandle_t         *dimensions;    // declare pointer
>> >>>
>> >>> /* get the dimension info for all dimensions*/
>> >>> dimensions = (midimhandle_t) malloc( sizeof(struct midimhandle_t) *
>> >>> nDimensions );
>> >>
>> >> Try this:
>> >>
>> >>             = (midimhandle_t*) malloc( ... )
>
> I deleted the original message, so I no longer have the 1st error. But
> let me guess...
>
> midimhandle_t is a typedef of a struct, so don't use struct.
>
> dimensions = (midimhandle_t *) malloc( sizeof( midimhandle_t ) * nDimensions );
>
>
>
>



-- 
=================================
Jim Nikelski, Ph.D.
Postdoctoral Research Fellow
Bloomfield Centre for Research in Aging
Lady Davis Institute for Medical Research
Sir Mortimer B. Davis - Jewish General Hospital
McGill University



More information about the MINC-users mailing list