4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
42 #define ERR_MEMORY "memory allocation failure, errno=%d"
45 * using factor of eight limits maximum
46 * memory fragmentation to 12.5%
48 #define MEMSIZ PATH_MAX*8
55 static struct dup
*head
, *tail
, *new;
57 static int size
, initialized
;
58 static void pathinit();
59 static void growstore();
62 * These functions allocate space for all the path names required
63 * in the packaging code. They are all allocated here so as to reduce
64 * memory fragmentation.
67 /* Initialize storage area. */
74 /* free all memory used except initial structure */
88 /* Allocate additional space for storage area. */
92 /* need more memory */
93 new = calloc(1, sizeof (struct dup
));
95 progerr(gettext(ERR_MEMORY
), errno
);
106 /* Allocate and return a pointer. If n == 0, initialize. */
119 n
++; /* Account for terminating null. */
124 pt
= &tail
->mem
[MEMSIZ
-size
];
131 /* Allocate and insert a pathname returning a pointer to the new string. */
145 n
= strlen(s
) + 1; /* string + null terminator */
150 pt
= &tail
->mem
[MEMSIZ
-size
];
153 (void) strcpy(pt
, s
);