C help wanted

R.Thomas rbt at sftig.UUCP
Sun Nov 11 08:05:27 AEST 1984


> ~|  i have a program that generates a rather complex model of an object
> ~| (this is for computer graphics) that is composed of records. each record
> ~| contains data and pointers to other records. this entire data structure
> ~| is irregular. how can i save this structure in a file so that it can
> ~| be used by another program? keep in mind that this structure is not
> ~| tree-like in any way; it more closely resembles something a spider did
> ~| under influence of drugs.
> 
> Store all the data in structures declared in consecutive locations
> in memory, and save it in a file with a single write(2) call with address
> beginning at the start of all the records, and a size large enough to cover
> all the data. Read it in the same way. It's cheating, but it works.
> 
One more thing that makes this a little easier is to keep all pointers
relative to the beginning of the area you will write out.  This way
you can read it all back in to a different porgram without having to
adjust all the pointers for the offset between the old beginning
address and the new one.

Rick Thomas



More information about the Comp.unix mailing list