summaryrefslogtreecommitdiff
path: root/src/string_list.c
blob: b39ecd6fc9156b76a75632db0b9d001f677142ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "angband.h"

int compare_string_list(string_list *a, string_list *b)
{
	if (a == b)
	{
		return 0;
	}

	return strcmp(a->s, b->s);
}

SGLIB_DEFINE_LIST_FUNCTIONS(string_list, compare_string_list, next);

/*
 * Initialize a string_list value. Copies the input string.
 */
void string_list_init(string_list *sl, cptr s)
{
	assert(sl != NULL);

	sl->s = string_make(s);
	sl->next = NULL;
}

/*
 * Destroy string_value.
 */
void string_list_destroy(string_list *sl)
{
	assert(sl != NULL);

	if (sl->s) {
		string_free(sl->s);
		sl->s = NULL;
	}

	/* We do NOT free the rest of the list. */
	sl->next = NULL;
}