add_elem.c 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*!
  2. \file lib/manage/add_elem.c
  3. \brief Manage Library - Add element to the list
  4. (C) 2001-2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Original author CERL
  8. */
  9. #include <grass/gis.h>
  10. #include "manage_local_proto.h"
  11. /*!
  12. \brief Add element to the list
  13. \param elem element name
  14. \param desc description of the element
  15. */
  16. void M__add_element(const char *elem, const char *desc)
  17. {
  18. int n;
  19. int nelem;
  20. if (*desc == 0)
  21. desc = elem;
  22. n = nlist - 1;
  23. nelem = list[n].nelem++;
  24. list[n].element = G_realloc(list[n].element, (nelem + 1) * sizeof(const char *));
  25. list[n].element[nelem] = G_store(elem);
  26. list[n].desc = G_realloc(list[n].desc, (nelem + 1) * sizeof(const char *));
  27. list[n].desc[nelem] = G_store(desc);
  28. }