[PVFS-users] A query

Rob Ross rross at mcs.anl.gov
Mon May 24 08:09:24 EDT 2004


Hi,

If you place an array at the end of a C structure like that you have 
built the capability for a variably sized array in the structure.

If you allocate the structure dynamically with space for additional
elements, you can then use the elements just fine.  You'll see instances 
of malloc(sizeof(struct fs_info) + (N-1) * sizeof(iod_info)); that is 
where we are allocating the space for the structure plus (N-1) additional 
elements.

Regards,

Rob

On Mon, 24 May 2004, Mahesh Salunkhe wrote:

> Hi!
>  In fs_info structure there is an array of iod_info
> stuct of size 1.
> 	struct fs_info {
> 	.
> 	.
> 	.
> 	iod_info iod[1];
> 	}
> 	
> 	But,the indices greater than 1 are also reffered for
> getting info. of iods.E.g. ,in the do_statfs()
> function,a reference like following is made:
>    
> 	fs_p->iod[i].ack.ack.statfs.tot_bytes
> 
>         the array is of size 1 and higher indices are
> also being used.How does it work,I haven't
> understood.(I wrote a simlpe program to see whether
> this type of access is allowed,but it didn,t work.)
> What technique r u using there?



More information about the PVFS-users mailing list