Root/qpkg/pkg.c

Source at commit 761eae16bdfe2f97e34a927fd8fd9d14a9a18cc2 created 9 years 1 month ago.
By Werner Almesberger, labsw/: added hardware revision indication
1/*
2 * pkg.c - Package structure and operations
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include <stdlib.h>
15
16#include "util.h"
17#include "jrb.h"
18#include "pkg.h"
19
20
21
22struct pkg *new_pkg(struct jrb *jrb)
23{
24    struct pkg *pkg;
25
26    pkg = alloc_type(struct pkg);
27
28    pkg->id = jrb->key;
29    pkg->more = jrb->val;
30    jrb->val = pkg;
31    pkg->version = NULL;
32    pkg->arch = NULL;
33    pkg->conflicts = pkg->depends = pkg->provides = NULL;
34    pkg->filename = NULL;
35    pkg->flags = 0;
36    pkg->mark = 0;
37
38    return pkg;
39}
40
41
42static void free_refs(struct ref *refs)
43{
44    struct ref *next;
45
46    while (refs) {
47        next = refs->next;
48        free(refs);
49        refs = next;
50    }
51}
52
53
54void free_pkg(struct pkg *pkg)
55{
56    free_refs(pkg->conflicts);
57    free_refs(pkg->depends);
58    free_refs(pkg->provides);
59    free(pkg);
60}
61

Archive Download this file

Branches:
master



interactive