sized_array.c revision 1fcced4c370617db71610fecffd5451a5894ca5e
69fe9aaafdd6a141610e86a777d325db75422070Mark Andrews * CDDL HEADER START
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * The contents of this file are subject to the terms of the
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff * Common Development and Distribution License (the "License").
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff * You may not use this file except in compliance with the License.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * See the License for the specific language governing permissions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * and limitations under the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * When distributing Covered Code, include this CDDL HEADER in each
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * If applicable, add the following below this CDDL HEADER, with the
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff * fields enclosed by brackets "[]" replaced with your own identifying
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews * information: Portions Copyright [yyyy] [name of copyright owner]
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews * CDDL HEADER END
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
6d208969b3ed736f434bc5120044f8fd2f595f22David Lawrence * Use is subject to license terms.
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews * Much like calloc, but with functions to report the size of the
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews * allocation given only the pointer.
6d208969b3ed736f434bc5120044f8fd2f595f22David Lawrence * Assumes that int is at least 32 bits and that nothing needs more than
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * 8-byte alignment.
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews/* COOKIE provides some bad-pointer protection. */
c4ef94b1a270ab01d0ca50ecbc1df7fcdf6fc44fMark Andrews (void) memcpy(sa->cookie, COOKIE, sizeof (sa->cookie));
sized_array_free(void *p)
if (p == NULL)
#if defined(COOKIE)
sized_array_n(void *p)
#if defined(COOKIE)
return (sa->n);
sized_array_sz(void *p)
#if defined(COOKIE)