blob: c022acd748fec9006ad1276476d427a2b801001f (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <error.h>
#include <errno.h>
#include "prov.h"
#include "str.h"
prov_t *prov_new(void)
{
prov_t *pp = malloc(sizeof(prov_t));
if (!pp)
error(2, errno, "%s", __FUNCTION__);
pp->prov = strarg_new(&pp->nprov);
return pp;
}
void prov_free(prov_t *pp)
{
if (!pp)
return;
strarg_free(pp->prov, pp->nprov);
free(pp);
pp = NULL;
}
void prov_add(prov_t *pp, const char *name)
{
if (!pp)
pp = prov_new();
pp->prov = strarg_add(pp->prov, &pp->nprov, name);
}
prov_t *prov_copy(prov_t *source)
{
int n;
prov_t *tgt = prov_new();
if (!source)
goto out;
for (n = 0; n < source->nprov; n++)
prov_add(tgt, source->prov[n]);
out:
return tgt;
}
|