Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site sftig.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!akgua!whuxlm!whuxl!houxm!mhuxj!mhuxr!mhuxv!mhuxt!mhuxm!sftig!rbt From: rbt@sftig.UUCP (R.Thomas) Newsgroups: net.unix Subject: Re: C help wanted Message-ID: <474@sftig.UUCP> Date: Sat, 10-Nov-84 17:05:27 EST Article-I.D.: sftig.474 Posted: Sat Nov 10 17:05:27 1984 Date-Received: Tue, 13-Nov-84 05:27:31 EST References: <19300024@uiucdcsb.UUCP> <421@utcsrgv.UUCP> Organization: AT&T Bell Laboratories, Summit, NJ Lines: 20 > ~| 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