mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
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>
This commit is contained in:
parent
6b07b5d345
commit
92ab7c33fb
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef _ALPM_LIST_H
|
||||
#define _ALPM_LIST_H
|
||||
|
||||
#include <stdlib.h> /* size_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
55
lib/libalpm/graph.h
Normal file
55
lib/libalpm/graph.h
Normal file
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user