2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; only version 2 of the License is applicable.
6 * This program is distributed in the hope that it will be useful, but
7 * WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 * General Public License for more details.
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 # define random() rand()
23 # define srandom(x) srand(x)
27 /* make sure that the random number generator seeded EXACTLY ONCE */
30 static int rand_init = 0;
32 srandom((unsigned int) time(NULL) + (unsigned int) getpid());
39 /* rrd_add_ptr: add a pointer to a dynamically sized array of pointers,
40 * realloc as necessary. returns 1 on success, 0 on failure.
43 int rrd_add_ptr(void ***dest, size_t *dest_size, void *src)
49 temp = (void **) rrd_realloc(*dest, (*dest_size+1) * sizeof(*dest));
54 temp[*dest_size] = src;
60 /* like rrd_add_ptr, but calls strdup() on a string first. */
61 int rrd_add_strdup(char ***dest, size_t *dest_size, char *src)
69 dup_src = strdup(src);
73 add_ok = rrd_add_ptr((void ***)dest, dest_size, (void *)dup_src);
80 void rrd_free_ptrs(void ***src, size_t *cnt)