2 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Library General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2 of the License, or (at your option) any later version.
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Library General Public License for more details.
14 ** You should have received a copy of the GNU Library General Public
15 ** License along with this library; if not, write to the Free
16 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 #include "dbprim_int.h"
26 /** \ingroup dbprim_smat
28 * This function dynamically initializes a sparse matrix table.
30 * \param table A pointer to a #smat_table_t to be initialized.
31 * \param flags A bit-wise OR of #HASH_FLAG_AUTOGROW and
32 * #HASH_FLAG_AUTOSHRINK. If neither behavior is
35 * A #hash_resize_t function pointer for determining
36 * whether resizing is permitted and/or for notification
38 * \param extra Extra pointer data that should be associated with the
39 * sparse matrix table.
41 * An initial modulus for the table. This will
42 * presumably be extracted by st_modulus() in a previous
43 * invocation of the application. A 0 value is valid.
45 * \retval DB_ERR_BADARGS An invalid argument was given.
46 * \retval ENOMEM Unable to allocate memory.
49 st_init(smat_table_t *table, unsigned long flags, smat_resize_t resize,
50 void *extra, unsigned long init_mod)
54 initialize_dbpr_error_table(); /* set up error tables */
56 if (!table) /* verify arguments */
57 return DB_ERR_BADARGS;
59 table->st_resize = resize;
61 /* initialize the hash table */
62 if ((retval = ht_init(&table->st_table, flags, _smat_hash, _smat_comp,
63 _smat_resize, extra, init_mod)))
66 table->st_magic = SMAT_TABLE_MAGIC; /* initialize the rest of the table */