Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-02-15 20:57:30 -0600
committerDan McGee <dan@archlinux.org>2008-02-16 11:58:49 -0600
commit92ab7c33fb4d72eba070636f620f595dc4650ee9 (patch)
treeb2f70b7ee2b240868a8701e9a48fa3d778559378 /lib
parent6b07b5d34512ef361ebf04395f07965cb80d0ec3 (diff)
Move pmgraph_t struct and functions to their own header file
This will allow us to utilize this helpful type and functions in places besides dependency calculations. In addition, remove the public declaration of pmgraph_t in alpm.h- there is zero need to expose this internal type. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/Makefile.am1
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/alpm_list.h2
-rw-r--r--lib/libalpm/deps.c30
-rw-r--r--lib/libalpm/deps.h10
-rw-r--r--lib/libalpm/graph.h55
6 files changed, 61 insertions, 38 deletions
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 6549066f..6f166bfa 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -28,6 +28,7 @@ libalpm_la_SOURCES = \
delta.h delta.c \
deps.h deps.c \
error.h error.c \
+ graph.h \
group.h group.c \
handle.h handle.c \
log.h log.c \
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index b19e1dd9..a6807191 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -52,7 +52,6 @@ typedef struct __pmdepend_t pmdepend_t;
typedef struct __pmdepmissing_t pmdepmissing_t;
typedef struct __pmconflict_t pmconflict_t;
typedef struct __pmfileconflict_t pmfileconflict_t;
-typedef struct __pmgraph_t pmgraph_t;
/*
* Library
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index ae373910..057b6b5c 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -19,6 +19,8 @@
#ifndef _ALPM_LIST_H
#define _ALPM_LIST_H
+#include <stdlib.h> /* size_t */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index c08c59e9..29dafc29 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -31,6 +31,7 @@
#include "util.h"
#include "log.h"
#include "error.h"
+#include "graph.h"
#include "package.h"
#include "db.h"
#include "cache.h"
@@ -43,31 +44,6 @@ void _alpm_dep_free(pmdepend_t *dep)
FREE(dep);
}
-static pmgraph_t *_alpm_graph_new(void)
-{
- pmgraph_t *graph = NULL;
-
- ALPM_LOG_FUNC;
-
- MALLOC(graph, sizeof(pmgraph_t), RET_ERR(PM_ERR_MEMORY, NULL));
-
- if(graph) {
- graph->state = 0;
- graph->data = NULL;
- graph->parent = NULL;
- graph->children = NULL;
- graph->childptr = NULL;
- }
- return(graph);
-}
-
-static void _alpm_graph_free(void *data)
-{
- pmgraph_t *graph = data;
- alpm_list_free(graph->children);
- free(graph);
-}
-
pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdepend_t *dep,
const char *causingpkg)
{
@@ -97,7 +73,7 @@ void _alpm_depmiss_free(pmdepmissing_t *miss)
* Returns a list of vertices (one vertex = one package)
* (used by alpm_sortbydeps)
*/
-static alpm_list_t *_alpm_graph_init(alpm_list_t *targets)
+static alpm_list_t *dep_graph_init(alpm_list_t *targets)
{
alpm_list_t *i, *j, *k;
alpm_list_t *vertices = NULL;
@@ -161,7 +137,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode)
_alpm_log(PM_LOG_DEBUG, "started sorting dependencies\n");
- vertices = _alpm_graph_init(targets);
+ vertices = dep_graph_init(targets);
vptr = vertices;
vertex = vertices->data;
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index 439a92a2..0c3975e6 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -40,16 +40,6 @@ struct __pmdepmissing_t {
char *causingpkg; /* this is used in case of remove dependency error only */
};
-/* Graphs */
-struct __pmgraph_t {
- int state; /* 0: untouched, -1: entered, other: leaving time */
- void *data;
- struct __pmgraph_t *parent; /* where did we come from? */
- alpm_list_t *children;
- alpm_list_t *childptr; /* points to a child in children list */
-};
-
-
void _alpm_dep_free(pmdepend_t *dep);
pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep);
pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdepend_t *dep,
diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h
new file mode 100644
index 00000000..e3e40023
--- /dev/null
+++ b/lib/libalpm/graph.h
@@ -0,0 +1,55 @@
+/*
+ * graph.h - helpful graph structure and setup/teardown methods
+ *
+ * Copyright (c) 2002-2008 by Judd Vinet <jvinet@zeroflux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "alpm_list.h"
+#include "util.h" /* MALLOC() */
+#include "alpm.h"
+
+struct __pmgraph_t {
+ char state; /* 0: untouched, -1: entered, other: leaving time */
+ void *data;
+ struct __pmgraph_t *parent; /* where did we come from? */
+ alpm_list_t *children;
+ alpm_list_t *childptr; /* points to a child in children list */
+};
+typedef struct __pmgraph_t pmgraph_t;
+
+static pmgraph_t *_alpm_graph_new(void)
+{
+ pmgraph_t *graph = NULL;
+
+ MALLOC(graph, sizeof(pmgraph_t), RET_ERR(PM_ERR_MEMORY, NULL));
+
+ if(graph) {
+ graph->state = 0;
+ graph->data = NULL;
+ graph->parent = NULL;
+ graph->children = NULL;
+ graph->childptr = NULL;
+ }
+ return(graph);
+}
+
+static void _alpm_graph_free(void *data)
+{
+ pmgraph_t *graph = data;
+ alpm_list_free(graph->children);
+ free(graph);
+}
+