only include if USE_STRTBL is defined. (deleteStrItem): same. (hashStr):

2002-04-01  Chris Toshok  <toshok@ximian.com>

	* libversit/vobject.c (newStrItem): only include if USE_STRTBL is
	defined.
	(deleteStrItem): same.
	(hashStr): same.
	(lookupStr): if USE_STRTBL is defined, use existing behavior.  if
	not defined, just dup the string.
	(unUseStr): if USE_STRTBL is defined, use existing behavior.  if

svn path=/trunk/; revision=16314
This commit is contained in:
Chris Toshok 2002-04-01 20:38:38 +00:00 committed by Chris Toshok
parent 5dd03b7e76
commit 7f497424b6
2 changed files with 27 additions and 1 deletions

View File

@ -1,3 +1,14 @@
2002-04-01 Chris Toshok <toshok@ximian.com>
* libversit/vobject.c (newStrItem): only include if USE_STRTBL is
defined.
(deleteStrItem): same.
(hashStr): same.
(lookupStr): if USE_STRTBL is defined, use existing behavior. if
not defined, just dup the string.
(unUseStr): if USE_STRTBL is defined, use existing behavior. if
not defined, just free the string.
2002-04-01 Dan Winship <danw@ximian.com> 2002-04-01 Dan Winship <danw@ximian.com>
Darwin/OS X portability from Max Horn <max@quendi.de> Darwin/OS X portability from Max Horn <max@quendi.de>

View File

@ -48,6 +48,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#define USE_STRTBL
#define NAME_OF(o) o->id #define NAME_OF(o) o->id
#define VALUE_TYPE(o) o->valType #define VALUE_TYPE(o) o->valType
@ -142,6 +143,7 @@ DLLEXPORT(void) deleteStr(const char *p)
} }
#ifdef USE_STRTBL
static StrItem* newStrItem(const char *s, StrItem *next) static StrItem* newStrItem(const char *s, StrItem *next)
{ {
StrItem *p = (StrItem*)malloc(sizeof(StrItem)); StrItem *p = (StrItem*)malloc(sizeof(StrItem));
@ -155,7 +157,7 @@ static void deleteStrItem(StrItem *p)
{ {
free((void*)p); free((void*)p);
} }
#endif
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
The following function provide accesses to VObject's value. The following function provide accesses to VObject's value.
@ -609,6 +611,7 @@ DLLEXPORT(void) cleanVObjects(VObject *list)
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
The following is a String Table Facilities. The following is a String Table Facilities.
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
#ifdef USE_STRTBL
#define STRTBLSIZE 255 #define STRTBLSIZE 255
@ -624,8 +627,11 @@ static unsigned int hashStr(const char *s)
return h % STRTBLSIZE; return h % STRTBLSIZE;
} }
#endif
DLLEXPORT(const char*) lookupStr(const char *s) DLLEXPORT(const char*) lookupStr(const char *s)
{ {
#ifdef USE_STRTBL
StrItem *t; StrItem *t;
unsigned int h = hashStr(s); unsigned int h = hashStr(s);
if ((t = strTbl[h]) != 0) { if ((t = strTbl[h]) != 0) {
@ -640,10 +646,14 @@ DLLEXPORT(const char*) lookupStr(const char *s)
s = dupStr(s,0); s = dupStr(s,0);
strTbl[h] = newStrItem(s,strTbl[h]); strTbl[h] = newStrItem(s,strTbl[h]);
return s; return s;
#else
return dupStr(s, 0);
#endif
} }
DLLEXPORT(void) unUseStr(const char *s) DLLEXPORT(void) unUseStr(const char *s)
{ {
#ifdef USE_STRTBL
StrItem *t, *p; StrItem *t, *p;
unsigned int h = hashStr(s); unsigned int h = hashStr(s);
if ((t = strTbl[h]) != 0) { if ((t = strTbl[h]) != 0) {
@ -667,10 +677,14 @@ DLLEXPORT(void) unUseStr(const char *s)
t = t->next; t = t->next;
} while (t); } while (t);
} }
#else
deleteStr (s);
#endif
} }
DLLEXPORT(void) cleanStrTbl() DLLEXPORT(void) cleanStrTbl()
{ {
#ifdef USE_STRTBL
int i; int i;
for (i=0; i<STRTBLSIZE;i++) { for (i=0; i<STRTBLSIZE;i++) {
StrItem *t = strTbl[i]; StrItem *t = strTbl[i];
@ -683,6 +697,7 @@ DLLEXPORT(void) cleanStrTbl()
} while (t); } while (t);
strTbl[i] = 0; strTbl[i] = 0;
} }
#endif
} }