diglib/list.c

Go to the documentation of this file.
00001 /*
00002 * $Id: list.c,v 1.6 2006/02/09 03:08:58 glynn Exp $
00003 *
00004 ****************************************************************************
00005 *
00006 * MODULE:       Vector library 
00007 *               
00008 * AUTHOR(S):    Original author CERL, probably Dave Gerdes.
00009 *               Update to GRASS 5.7 Radim Blazek.
00010 *
00011 * PURPOSE:      Lower level functions for reading/writing/manipulating vectors.
00012 *
00013 * COPYRIGHT:    (C) 2001 by the GRASS Development Team
00014 *
00015 *               This program is free software under the GNU General Public
00016 *               License (>=v2). Read the file COPYING that comes with GRASS
00017 *               for details.
00018 *
00019 *****************************************************************************/
00020 #include <stdlib.h>
00021 #include <grass/gis.h>
00022 #include <grass/Vect.h>
00023 
00024 /* Init int_list */
00025 int 
00026 dig_init_list ( struct ilist *list ) 
00027 {
00028     list->value = NULL;
00029     list->n_values = 0;
00030     list->alloc_values = 0;
00031     
00032     return 1;
00033 }
00034 
00035 /* Init add item to list */
00036 int 
00037 dig_list_add ( struct ilist *list, int val ) 
00038 {
00039     void *p;
00040     int  size;
00041     
00042     if ( list->n_values == list->alloc_values ) {
00043         size = (list->n_values + 1000) * sizeof(int);
00044         p = realloc ( (void *) list->value, size ); 
00045         if ( p == NULL ) return 0;
00046         list->value = (int *) p;
00047         list->alloc_values = list->n_values + 1000; 
00048     }
00049    
00050     list->value[list->n_values] = val;
00051     list->n_values++;
00052 
00053     return 1;
00054 }

Generated on Sun Apr 6 17:32:44 2008 for GRASS by  doxygen 1.5.5