CVS/
sog/CVS/
sog/area/
sog/area/CVS/
sog/backup/
sog/backup/CVS/
sog/bin/
sog/bin/CVS/
sog/clans/CVS/
sog/clans/plists/
sog/clans/plists/CVS/
sog/classes/CVS/
sog/corefiles/
sog/corefiles/CVS/
sog/doc/CVS/
sog/doc/SoG/
sog/doc/SoG/CVS/
sog/doc/cvsup/
sog/doc/cvsup/CVS/
sog/doc/olc/CVS/
sog/etc/CVS/
sog/gods/
sog/gods/CVS/
sog/lang/CVS/
sog/log/
sog/log/CVS/
sog/notes/
sog/notes/CVS/
sog/player/
sog/player/CVS/
sog/races/CVS/
sog/src/CVS/
sog/src/comm/CVS/
sog/src/compat/
sog/src/compat/CVS/
sog/src/compat/mkdep/
sog/src/compat/mkdep/CVS/
sog/src/compat/regex-win32/CVS/
sog/src/db/CVS/
sog/src/mudprogs/CVS/
sog/src/olc/CVS/
sog/tmp/
sog/tmp/CVS/
/*-
 * Copyright (c) 1998 fjoe <fjoe@iclub.nsu.ru>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $Id: varr.h,v 1.5 1999/03/08 13:56:05 fjoe Exp $
 */

#ifndef _VARR_H_
#define _VARR_H_

typedef struct varr varr;
struct varr {
	size_t nsize;		/* size of elem */
	size_t nstep;		/* allocation step */

	void *p;

	size_t nused;		/* elems used */
	size_t nalloc;		/* elems allocated */
};

varr *	varr_new	(size_t nsize, size_t nstep);
void	varr_free	(varr*);
void *	varr_touch	(varr*, size_t i);
void *	varr_insert	(varr*, size_t i);
void	varr_del	(varr*, void*);
void	varr_qsort	(varr*, int (*)(const void*, const void*));
void *	varr_bsearch	(varr*, const void *e,
			 int (*)(const void*, const void*));

#define varr_enew(v)	(varr_touch((v), (v)->nused))
#define VARR_GET(v, i)	((void*) (((char*) (v)->p) + (i)*(v)->nsize))
#define varr_get(v, i)	((i) < 0 || (i) >= (v)->nused ? \
			 NULL : VARR_GET((v), (i)))

#endif