2008-02-15 21:57:30 -05:00
|
|
|
/*
|
|
|
|
* graph.h - helpful graph structure and setup/teardown methods
|
|
|
|
*
|
2011-01-05 23:45:15 -05:00
|
|
|
* Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
|
2009-07-01 03:08:33 -04:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2008-02-15 21:57:30 -05:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-06-01 22:47:31 -04:00
|
|
|
#include <sys/types.h> /* off_t */
|
|
|
|
|
2008-02-15 21:57:30 -05:00
|
|
|
#include "alpm_list.h"
|
2011-02-14 17:30:49 -05:00
|
|
|
#include "util.h" /* CALLOC() */
|
2008-02-15 21:57:30 -05:00
|
|
|
|
|
|
|
struct __pmgraph_t {
|
|
|
|
char state; /* 0: untouched, -1: entered, other: leaving time */
|
|
|
|
void *data;
|
2008-06-01 22:47:31 -04:00
|
|
|
off_t weight; /* weight of the node */
|
2008-02-15 21:57:30 -05:00
|
|
|
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;
|
|
|
|
|
2011-02-14 17:30:49 -05:00
|
|
|
CALLOC(graph, 1, sizeof(pmgraph_t), RET_ERR(PM_ERR_MEMORY, NULL));
|
2008-02-15 21:57:30 -05:00
|
|
|
return(graph);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _alpm_graph_free(void *data)
|
|
|
|
{
|
|
|
|
pmgraph_t *graph = data;
|
|
|
|
alpm_list_free(graph->children);
|
|
|
|
free(graph);
|
|
|
|
}
|
|
|
|
|