]>
Commit | Line | Data |
---|---|---|
6dfbe297 CF |
1 | /* |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by Ron Parker <parkerrd@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
853b9e91 CF |
16 | /* strarry.c: implementation of the strarry struct routines. */ |
17 | #include <malloc.h> | |
20904de1 | 18 | #include <windows.h> |
853b9e91 CF |
19 | #include "setup.h" |
20 | #include "strarry.h" | |
608de931 CF |
21 | |
22 | void | |
853b9e91 | 23 | sa_init (SA * array) |
93014d67 | 24 | { |
608de931 CF |
25 | array->count = 0; |
26 | array->array = NULL; | |
27 | } | |
28 | ||
29 | void | |
853b9e91 | 30 | sa_add (SA * array, const char *str) |
93014d67 | 31 | { |
608de931 | 32 | array->array = array->count |
853b9e91 | 33 | ? xrealloc (array->array, sizeof (char *) * (array->count + 1)) |
608de931 CF |
34 | : xmalloc (sizeof (char *)); |
35 | array->array[array->count++] = xstrdup (str); | |
36 | } | |
37 | ||
38 | void | |
853b9e91 | 39 | sa_cleanup (SA * array) |
93014d67 | 40 | { |
608de931 CF |
41 | size_t n = array->count; |
42 | while (n--) | |
43 | xfree (array->array[n]); | |
44 | xfree (array->array); | |
45 | } |