Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed LinkedStringList and related code.
  • Loading branch information
icculus committed Sep 29, 2004
1 parent 0492580 commit c2c71fb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 140 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -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
Expand Down
124 changes: 0 additions & 124 deletions physfs.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 0 additions & 16 deletions physfs_internal.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c2c71fb

Please sign in to comment.