fix a bad api

This commit is contained in:
tTh 2023-03-30 05:05:32 +02:00
parent 3d93b66b00
commit a1e5058d97
2 changed files with 15 additions and 9 deletions

22
edges.c
View File

@ -16,7 +16,9 @@ EdgeList * alloc_edgelist(char *name, int sz, int flags)
EdgeList *elptr;
AnEdge *array;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d 0x%X )\n", __func__, name, sz, flags);
#endif
if (NULL==(elptr = calloc(1, sizeof(EdgeList)))) {
fprintf(stderr, "no mem available in %s\n", __func__);
@ -45,8 +47,9 @@ return elptr;
/* --------------------------------------------------------------------- */
int free_edgelist(EdgeList *list, int k)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p 0x%X )\n", __func__, list, k);
#endif
if (k) {
fprintf(stderr, "%s: k must be 0, was %d\n", __func__, k);
@ -132,26 +135,28 @@ return 0; /* NOT FOUND */
int print_edgelist_desc(EdgeList *list, int k)
{
fprintf(stderr, "--- edgelist '%s' at %p\n", list->name, list);
fprintf(stderr, "------- edgelist '%s' at %p\n", list->name, list);
if (k) {
fprintf(stderr, "%s: k must be 0, was %d\n", __func__, k);
return k;
}
fprintf(stderr, "\tarray @ %p\n", list->edges);
fprintf(stderr, "\tsize %8d\n", list->size);
fprintf(stderr, "\tnext free %8d\n", list->fidx);
// fprintf(stderr, "\tmagic 0x%08X\n", list->magic);
fprintf(stderr, "\tarray @ %p\n", list->edges);
fprintf(stderr, "\tsize %8d\n", list->size);
fprintf(stderr, "\tnext free %8d\n", list->fidx);
fprintf(stderr, "\tmagic 0x%08lX\n", list->magic);
return 0;
}
/* --------------------------------------------------------------------- */
int print_the_edges(EdgeList *list, int k)
int print_the_edges(FILE *fp, EdgeList *list, int k)
{
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, list, k);
#endif
if (k) {
fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k);
@ -161,7 +166,8 @@ if (k) {
fprintf(stderr, " list.fidx = %d\n", list->fidx);
for (foo=0; foo<list->fidx; foo++) {
printf("%6d\t\t%5d %5d\n", foo, list->edges[foo].A, list->edges[foo].B);
fprintf(fp, "%6d\t\t%5d %5d\n", foo,
list->edges[foo].A, list->edges[foo].B);
}
return -1;

View File

@ -29,6 +29,6 @@ int push_a_missing_edge(EdgeList *list, int p0, int p1);
int is_edge_in_list(EdgeList *list, int p0, int p1);
int print_edgelist_desc(EdgeList *list, int k);
int print_the_edges(EdgeList *list, int k);
int print_the_edges(FILE *file, EdgeList *list, int k);
/* --------------------------------------------------------------------- */