so working "standard" library more decade of history brain image i/o. encountered function:
nifti_image* nifti_image_read( const char *hname , int read_data ){ nifti_image* nim; ... <<<some io operations>>> ... return nim; }
my question is, how come function returning local pointer automatic variable? isn't practice prohibited since nim pointer goes out of scope , supposed deleted after completion of function?
i have read this question couldn't answer:
this function returning value stored in pointer , ok. pointer value address of object allocated dynamically , not deleted @ end, if c++. possible issue case pointer points local variable, not allocated dynamically. though pointer goes out of scope, caller receives return value gets copy of address of valid object.
Comments
Post a Comment