添加edge的新建和释放函数

This commit is contained in:
建峰 2025-04-25 14:07:37 +08:00
parent 0520bb99ae
commit 6965fa1e25

View File

@ -359,6 +359,28 @@ static void greph_node_free(struct _graph_node** node)
}
}
static struct _graph_edge* graph_edge_new(void *obj, uint32_t obj_size)
{
struct _graph_edge* new_edge = (struct _graph_edge*)malloc(sizeof(struct _graph_edge));
if (new_edge == NULL)
{
return NULL;
}
new_edge->next = NULL;
new_edge->weight = 0;
new_edge->target = NULL;
return new_edge;
}
static void greph_edge_free(struct _graph_edge** edge)
{
if(edge != NULL && *edge != NULL)
{
free(*edge);
*edge = NULL;
}
}
static uint32_t graph_size(struct _graph* self)
{
if(self == NULL)