alist.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Create, manage, and destroy association lists. alists are arrays with
* arbitrary index types, and are also commonly known as associative arrays.
*/
#include <stdio.h>
#include <stdlib.h>
#include "alist.h"
#include "memory.h"
#include "hash.h"
#define ALIST_HASH_SIZE 997
struct alist {
void (*al_namefree)(void *);
void (*al_valfree)(void *);
};
typedef struct alist_el {
void *ale_name;
void *ale_value;
} alist_el_t;
static int
{
}
static int
{
}
alist_t *
int (*cmpfn)(void *, void *))
{
return (alist);
}
alist_t *
{
(int (*)())alist_hash, (int (*)())alist_cmp));
}
static void
{
if (alist->al_namefree)
if (alist->al_valfree)
}
void
{
}
void
{
alist_el_t *el;
}
int
{
return (0);
if (value)
return (1);
}
typedef struct alist_iter_data {
int (*aid_func)(void *, void *, void *);
void *aid_priv;
static int
{
}
int
{
}
/*
* Debugging support. Used to print the contents of an alist.
*/
void
{
printf("Alist statistics\n");
}
static int alist_def_print_cb_key_int = 1;
static int alist_def_print_cb_value_int = 1;
static int
{
printf("Key: ");
if (alist_def_print_cb_key_int == 1)
else
printf("Value: ");
if (alist_def_print_cb_value_int == 1)
else
return (1);
}
static int
{
return (1);
}
int
{
if (!printer)
}