2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 static char rcsid[] = "$Id: save.c,v 3.4 1994/06/24 10:35:14 ceriel Exp $";
10 * If everything is kept in core, we must save some things for the second pass.
20 extern char *core_alloc();
29 if ((p = core_alloc(ALLOMODL, (long)sizeof(int))) != (char *)0) {
30 *(unsigned short *)p = AALMAG;
31 core_position += sizeof(int);
43 if ((p=core_alloc(ALLOMODL,(long)sizeof(struct ar_hdr)))!=(char *)0) {
44 *(struct ar_hdr *)p = *hdr;
45 core_position += int_align(sizeof(struct ar_hdr));
49 long NLChars = 0; /* Size of string area for local names. */
50 long NGChars = 0; /* Idem for global names. */
53 * Put the string in cp into the block allocated for the string area.
54 * Return its offset in this area. We don't use the first char of the string
55 * area, so that empty strings can be distinguished from the first string.
63 register ind_t newoff;
66 extern ind_t hard_alloc();
67 extern char *strcpy();
72 len = strlen(modulptr(off)) + 1;
73 if (piece == ALLOLCHR) {
75 if (!incore || (newoff = alloc(piece, len)) == BADOFF)
78 assert(piece == ALLOGCHR);
80 if ((newoff = hard_alloc(piece, len)) == BADOFF)
83 strcpy(address(piece, newoff), modulptr(off));
88 * Put the local in `name' in the piece allocated for local names that must
89 * be saved. `Name' points to a private copy, so will not become invalid after
90 * allocation, but the string of which name->on_foff is the offset may be
91 * destroyed, so we save that first.
99 if ((savindex = savechar(ALLOLCHR, (ind_t)name->on_foff)) == BADOFF)
102 new = (struct outname *)
103 core_alloc(ALLOLOCL, (long)sizeof(struct outname));
104 if (new != (struct outname *)0) {
106 new->on_foff = savindex;