23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * CDDL HEADER START
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * The contents of this file are subject to the terms of the
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * Common Development and Distribution License (the "License").
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * You may not use this file except in compliance with the License.
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * or http://www.opensolaris.org/os/licensing.
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * See the License for the specific language governing permissions
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * and limitations under the License.
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * When distributing Covered Code, include this CDDL HEADER in each
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * If applicable, add the following below this CDDL HEADER, with the
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * fields enclosed by brackets "[]" replaced with your own identifying
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * information: Portions Copyright [yyyy] [name of copyright owner]
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * CDDL HEADER END
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner#define LINESZ 128 /* initial guess for a NULL *lineptr */
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulknergetdelim(char **_RESTRICT_KYWD lineptr, size_t *_RESTRICT_KYWD n,
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner if (*lineptr == NULL || *n < LINESZ) { /* initial allocation */
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner if ((*lineptr = realloc(*lineptr, LINESZ)) == NULL) {
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner c = (--iop->_cnt < 0) ? __filbuf(iop) : *iop->_ptr++;
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner if (++cnt == size) { /* must reallocate */
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner if ((ptr = realloc(*lineptr, 2 * size)) == NULL) {
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner } while (c != delimiter);