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