From 2ad270f0348da17ffcc1d8ab5d96513bbad82db9 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 14 Aug 2024 14:52:36 -0400 Subject: [PATCH] Working out the unidns module --- lib/subrou.c | 27 ++++++++++++++++++++++++++- lib/subrou.h | 5 ++++- lib/unidns.c | 32 ++++++++++++++++++++++++-------- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/lib/subrou.c b/lib/subrou.c index 9fa3673..61d85ec 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.4.2" -#define RELEASE "3" +#define RELEASE "4" //Public variables PUBLIC int debug=0; //debug level @@ -352,6 +352,31 @@ if ((list!=(void **)0)&&(entry!=(void **)0)) { return found; } /* + +*/ +/********************************************************/ +/* */ +/* Procedure to free all list entries, return a */ +/* NULL pointer. */ +/* */ +/********************************************************/ +PUBLIC void **rou_freelist(void **list,freehandler_t handler) + +{ +if (list!=(void **)0) { + void **ptr; + + ptr=list; + while (*ptr!=(void *)0) { + (void) handler(*ptr); + ptr++; + } + (void) free(list); + list=(void **)0; + } +return list; +} +/* ^L */ /********************************************************/ diff --git a/lib/subrou.h b/lib/subrou.h index 912f0d4..2e583bc 100644 --- a/lib/subrou.h +++ b/lib/subrou.h @@ -61,9 +61,12 @@ extern int rou_nbrlist(void **list); extern void **rou_addlist(void **list,void *entry); //Procedure to free one entry part of list -// return true if found, false otherwize. +//return true if found, false otherwise. extern _Bool rou_rmlist(void **list,void *entry,freehandler_t handler); +//Procedure to free all entries of list +extern void **rou_freelist(void **list,freehandler_t handler); + //change the application name extern char *rou_setappname(const char *newname); diff --git a/lib/unidns.c b/lib/unidns.c index dc07158..649c154 100644 --- a/lib/unidns.c +++ b/lib/unidns.c @@ -153,16 +153,13 @@ while((answer-->0)&&(cp\n",*ptr); ptr++; } + list=(char **)rou_freelist((void **)list,(freehandler_t)rou_freestr); } break; default : //SAFE guard -- 2.47.3