GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
add_elem.c
Go to the documentation of this file.
1/*!
2 \file lib/manage/add_elem.c
3
4 \brief Manage Library - Add element to the list
5
6 SPDX-FileCopyrightText: 2001-2011 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Original author CERL
10 */
11
12#include <grass/gis.h>
13
14#include "manage_local_proto.h"
15
16/*!
17 \brief Add element to the list
18
19 \param elem element name
20 \param desc description of the element
21 */
22void M__add_element(const char *elem, const char *desc)
23{
24 int n;
25 int nelem;
26
27 if (*desc == 0)
28 desc = elem;
29
30 n = nlist - 1;
31 nelem = list[n].nelem++;
32 list[n].element =
33 G_realloc(list[n].element, (nelem + 1) * sizeof(const char *));
34 list[n].element[nelem] = G_store(elem);
35 list[n].desc = G_realloc(list[n].desc, (nelem + 1) * sizeof(const char *));
36 list[n].desc[nelem] = G_store(desc);
37}
void M__add_element(const char *elem, const char *desc)
Add element to the list.
Definition add_elem.c:22
#define G_realloc(p, n)
Definition defs/gis.h:138
char * G_store(const char *)
Copy string to allocated memory.
Definition strings.c:85
int nlist
Definition read_list.c:21
Definition manage.h:4
const char ** desc
Definition manage.h:7
int nelem
Definition manage.h:9
const char ** element
Definition manage.h:5