From c2c71fb55f178653fabab7cb3560a1fd090a86da Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 29 Sep 2004 06:37:20 +0000 Subject: [PATCH] Removed LinkedStringList and related code. --- CHANGELOG | 2 + physfs.c | 124 ---------------------------------------------- physfs_internal.h | 16 ------ 3 files changed, 2 insertions(+), 140 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3ba09084..6e1c18fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,8 @@ archivers and moved their PHYSFS_Archiver data to the end of the file, since this was annoying me and I was getting sick of updating function signatures in two places when the internal API changed. + Removed the code/data for LinkedStringLists...it isn't used anymore + now that the callback code is in place. 09262004 - Did the same thing to FileHandles than I did to DirHandles, but this triggered massive tweaking in physfs.c. A lot of code got little cleanups, which was nice. Less malloc pressure, too, since diff --git a/physfs.c b/physfs.c index 16a46283..8eaa12de 100644 --- a/physfs.c +++ b/physfs.c @@ -1473,96 +1473,6 @@ const char *PHYSFS_getRealDir(const char *filename) return(retval); } /* PHYSFS_getRealDir */ -#if 0 -static int countList(LinkedStringList *list) -{ - int retval = 0; - LinkedStringList *i; - - for (i = list; i != NULL; i = i->next) - retval++; - - return(retval); -} /* countList */ - - -static char **convertStringListToPhysFSList(LinkedStringList *finalList) -{ - int i; - LinkedStringList *next = NULL; - int len = countList(finalList); - char **retval = (char **) malloc((len + 1) * sizeof (char *)); - - if (retval == NULL) - __PHYSFS_setError(ERR_OUT_OF_MEMORY); - - for (i = 0; i < len; i++) - { - next = finalList->next; - if (retval == NULL) - free(finalList->str); - else - retval[i] = finalList->str; - free(finalList); - finalList = next; - } /* for */ - - if (retval != NULL) - retval[i] = NULL; - - return(retval); -} /* convertStringListToPhysFSList */ - - -static void insertStringListItem(LinkedStringList **final, - LinkedStringList *item) -{ - LinkedStringList *i; - LinkedStringList *prev = NULL; - int rc; - - for (i = *final; i != NULL; i = i->next) - { - rc = strcmp(i->str, item->str); - if (rc > 0) /* insertion point. */ - break; - else if (rc == 0) /* already in list. */ - { - free(item->str); - free(item); - return; - } /* else if */ - prev = i; - } /* for */ - - /* - * If we are here, we are either at the insertion point. - * This may be the end of the list, or the list may be empty, too. - */ - if (prev == NULL) - *final = item; - else - prev->next = item; - - item->next = i; -} /* insertStringListItem */ - - -/* if we run out of memory anywhere in here, we give back what we can. */ -static void interpolateStringLists(LinkedStringList **final, - LinkedStringList *newList) -{ - LinkedStringList *next = NULL; - - while (newList != NULL) - { - next = newList->next; - insertStringListItem(final, newList); - newList = next; - } /* while */ -} /* interpolateStringLists */ -#endif - static int locateInStringList(const char *str, char **list, @@ -2128,40 +2038,6 @@ int PHYSFS_flush(PHYSFS_File *handle) } /* PHYSFS_flush */ -LinkedStringList *__PHYSFS_addToLinkedStringList(LinkedStringList *retval, - LinkedStringList **prev, - const char *str, - PHYSFS_sint32 len) -{ - LinkedStringList *l; - - l = (LinkedStringList *) malloc(sizeof (LinkedStringList)); - BAIL_IF_MACRO(l == NULL, ERR_OUT_OF_MEMORY, retval); - - if (len < 0) - len = strlen(str); - - l->str = (char *) malloc(len + 1); - if (l->str == NULL) - { - free(l); - BAIL_MACRO(ERR_OUT_OF_MEMORY, retval); - } /* if */ - - strncpy(l->str, str, len); - l->str[len] = '\0'; - - if (retval == NULL) - retval = l; - else - (*prev)->next = l; - - *prev = l; - l->next = NULL; - return(retval); -} /* __PHYSFS_addToLinkedStringList */ - - int PHYSFS_setAllocator(PHYSFS_Allocator *a) { BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0); diff --git a/physfs_internal.h b/physfs_internal.h index ad00f6ad..1dde2be2 100644 --- a/physfs_internal.h +++ b/physfs_internal.h @@ -924,13 +924,6 @@ struct __PHYSFS_DIRHANDLE__; struct __PHYSFS_FILEFUNCTIONS__; -typedef struct __PHYSFS_LINKEDSTRINGLIST__ -{ - char *str; - struct __PHYSFS_LINKEDSTRINGLIST__ *next; -} LinkedStringList; - - /* !!! FIXME: find something better than "dvoid" and "fvoid" ... */ /* Opaque data for file and dir handlers... */ typedef void dvoid; @@ -1193,15 +1186,6 @@ char *__PHYSFS_convertToDependent(const char *prepend, const char *dirName, const char *append); -/* - * Use this to build the list that your enumerate function should return. - * See zip.c for an example of proper use. - */ -LinkedStringList *__PHYSFS_addToLinkedStringList(LinkedStringList *retval, - LinkedStringList **prev, - const char *str, - PHYSFS_sint32 len); - /* This byteorder stuff was lifted from SDL. http://www.libsdl.org/ */ #define PHYSFS_LIL_ENDIAN 1234