WIP to make dtbuilder work on 64bit.

Fixes many, though not all 64bit-warnings.  In lots of places, pointers are
cast to ints to be then used as array subscripts.  The only way to deal with
this is to change them to long.  Additionally, use calloc() to allocate the
int_array in istr.c and drop the (wrong) macro patch to istr.h.  Should make
dtbuilder work on 32bit again.
This commit is contained in:
Pascal Stumpf
2012-08-13 17:35:34 +02:00
committed by Jon Trulson
parent 50e6c86bf4
commit 1177e21080
29 changed files with 138 additions and 134 deletions

View File

@@ -85,7 +85,7 @@ typedef struct BUCKET
*/
STRING Istr_null_string= "(nil)";
STRN *int_array= NULL; /* unique number array */
int num_count = 1; /* unique number counter */
long num_count = 1; /* unique number counter */
static BucketRec hashtable[NUMBUCKETS];
@@ -94,10 +94,10 @@ STRN *debug_istr= NULL; /* debugging shortcut for clients (see */
/* comment at top of this file) */
#endif /* DEBUG */
static int *freelist; /* freelist for unused numbers */
static long *freelist; /* freelist for unused numbers */
static int freecount = 0; /* freelist count */
static int hash_count = 0; /* total number that has been inserted */
static long freecount = 0; /* freelist count */
static long hash_count = 0; /* total number that has been inserted */
static unsigned hashing(
char *p
@@ -125,7 +125,7 @@ static int istrP_errmsg_noexist(int istr_value);
#define int_array_set(ptr) (int_array = (ptr))
#endif
#define istrP_int_to_client(intVal) ((ISTRING)(intVal))
#define istrP_client_to_int(istrVal) ((int)(istrVal))
#define istrP_client_to_int(istrVal) ((long)(istrVal))
#define return_istr(x) return istrP_int_to_client(x)
/*****************************************************************************/
@@ -142,7 +142,7 @@ istr_create (
)
{
int hashval;
int str_exists;
long str_exists;
Bucket new_bucket;
int i;
Bucket entry;
@@ -310,7 +310,7 @@ istrP_create_alloced_impl(
)
{
int hashval;
int str_exists;
long str_exists;
Bucket new_bucket;
int i;
Bucket entry;
@@ -487,7 +487,7 @@ istr_create_const(
)
{
int hashval;
int str_exists;
long str_exists;
Bucket new_bucket;
int i;
Bucket entry;
@@ -668,7 +668,7 @@ istr_dup_existing(
)
{
int hashval;
int str_exists;
long str_exists;
if (string == NULL)
{
@@ -696,7 +696,7 @@ istrP_destroy_impl(
ISTRING *istringClientPtr
)
{
int istring = (int)(*istringClientPtr);
long istring = (long)(*istringClientPtr);
int val; /* hashing value */
int i;
Bucket entry;
@@ -712,7 +712,7 @@ istrP_destroy_impl(
(int_array[istring].read_const == 0)))
{
istrP_errmsg_noexist(istring);
return NULL;
return 0;
}
if (int_array[istring].read_const == 1) /* const entry */
{
@@ -752,13 +752,13 @@ istrP_destroy_impl(
/* put unused int_array location of the freelist */
if(free_num == 0)
{
freelist = (int *)malloc(ARRAYSIZE * sizeof(int));
freelist = (long *)malloc(ARRAYSIZE * sizeof(long));
if (freelist == NULL)
{
fprintf(stderr,
catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 3,
"ISTR: error in allocating memory\n") );
return NULL ;
return 0 ;
}
free_num = 1;
}
@@ -771,15 +771,15 @@ istrP_destroy_impl(
else /* need more freelist space */
{
free_num++;
freelist = (int *)realloc(freelist,
(ARRAYSIZE * free_num) * sizeof(int));
freelist = (long *)realloc(freelist,
(ARRAYSIZE * free_num) * sizeof(long));
assert(freelist != NULL);
if (freelist == NULL)
{
fprintf(stderr,
catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 3,
"ISTR: error in allocating memory\n") );
return NULL ;
return 0 ;
}
freelist[freecount] = istring;
freecount++;
@@ -789,7 +789,7 @@ istrP_destroy_impl(
/*
* Set the client's variable to NULL
*/
istring = NULL;
istring = 0;
(*istringClientPtr) = istrP_int_to_client(istring);
return 1;
}
@@ -804,7 +804,7 @@ istr_dup(
ISTRING istringClientVal
)
{
int istring= istrP_client_to_int(istringClientVal);
long istring= istrP_client_to_int(istringClientVal);
if(istring == 0)
{
@@ -831,7 +831,7 @@ istrP_get_string_verify(
ISTRING istringClientVal
)
{
int istring = istrP_client_to_int(istringClientVal);
long istring = istrP_client_to_int(istringClientVal);
if(istring == 0)
{
@@ -932,13 +932,13 @@ insert_array(
if(hash_count == 0)
{
int_array_set((STRN *)malloc(ARRAYSIZE * sizeof(STRN)));
int_array_set((STRN *)calloc(ARRAYSIZE, sizeof(STRN)));
if (int_array == NULL)
{
fprintf(stderr,
catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 3,
"ISTR: error in allocating memory\n") );
return NULL ;
return 0 ;
}
array_num = 1;
}
@@ -973,7 +973,7 @@ insert_array(
fprintf(stderr,
catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 3,
"ISTR: error in allocating memory\n") );
return NULL ;
return 0 ;
}
int_array[val].refcount =1;
if (flag == 1)

View File

@@ -69,7 +69,7 @@ static int strlistP_build_user_data_array(
((((_list)->user_datas == NULL) && ((_data) != NULL))? \
strlistP_build_user_data_array(_list, _index, _data) \
: \
((int)((_list)->user_datas[(_index)] = (_data))) \
((long)((_list)->user_datas[(_index)] = (_data))) \
)
@@ -189,10 +189,10 @@ strlist_istr_exists(StringList list, ISTRING istring)
}
int
long
strlist_set_istr_data(StringList list, ISTRING istring, void *data)
{
int index = strlist_get_istr_index(list, istring);
long index = strlist_get_istr_index(list, istring);
if (index < 0)
{
return index;
@@ -215,10 +215,10 @@ strlist_get_istr_data(StringList list, ISTRING istring)
/*
* Returns the index of the given string, or -1 if it doesn't exist
*/
int
long
strlist_get_istr_index(StringList list, ISTRING string)
{
int index = -1;
long index = -1;
int i = 0;
int num_strings = list->num_strings;
@@ -293,10 +293,10 @@ epilogue:
}
int
long
strlist_remove_istr(StringList list, ISTRING istring)
{
int index = strlist_get_istr_index(list, istring);
long index = strlist_get_istr_index(list, istring);
if (index < 0)
{
return 0;
@@ -485,10 +485,10 @@ strlist_str_exists(StringList list, STRING string)
}
int
long
strlist_get_str_index(StringList list, STRING string)
{
int index = -1;
long index = -1;
ISTRING istring = istr_create(string);
if (istring != NULL)
{
@@ -506,10 +506,10 @@ strlist_get_str(StringList list, int whichString, void **clientDataOut)
}
int
long
strlist_remove_str(StringList list, STRING string)
{
int return_value = 0;
long return_value = 0;
ISTRING istring = istr_dup_existing(string);
if (istring != NULL)
{
@@ -520,10 +520,10 @@ strlist_remove_str(StringList list, STRING string)
}
int
long
strlist_set_str_data(StringList list, STRING string, void *data)
{
int return_value = 0;
long return_value = 0;
ISTRING istring = istr_dup_existing(string);
if (istring != NULL)
{
@@ -571,6 +571,7 @@ strlist_dup(StringList list)
**************************************************************************/
int
strlistP_shrink_array(StringList list, int sizeDiff)
{
int return_value = 0;

View File

@@ -104,12 +104,12 @@ int strlist_dump(StringList list);
* STRING interfaces
*/
int strlist_add_str(StringList, STRING s, void *userData);
int strlist_remove_str(StringList, STRING s);
long strlist_remove_str(StringList, STRING s);
BOOL strlist_str_exists(StringList list, STRING s);
int strlist_get_str_index(StringList list, STRING s);
long strlist_get_str_index(StringList list, STRING s);
STRING strlist_get_str(StringList,
int whichString, void **userDataOut);
int strlist_set_str_data(StringList, STRING string, void *data);
long strlist_set_str_data(StringList, STRING string, void *data);
void *strlist_get_str_data(StringList, STRING string);
StringList strlist_dup(StringList);
@@ -120,14 +120,14 @@ StringList strlist_dup(StringList);
* The STRINGs and ISTRING are kept in the same list, and behave identically
*/
int strlist_add_istr(StringList, ISTRING s, void *userData);
int strlist_add_index_istr(StringList,
long strlist_add_index_istr(StringList,
int index, ISTRING s, void *userData);
BOOL strlist_istr_exists(StringList list, ISTRING s);
int strlist_get_istr_index(StringList list, ISTRING s);
long strlist_get_istr_index(StringList list, ISTRING s);
ISTRING strlist_get_istr(StringList,
int whichString, void **userDataOut);
int strlist_set_istr_data(StringList, ISTRING istring, void *data);
long strlist_set_istr_data(StringList, ISTRING istring, void *data);
void *strlist_get_istr_data(StringList, ISTRING istring);
int strlist_remove_istr(StringList, ISTRING s);
long strlist_remove_istr(StringList, ISTRING s);
#endif /* _ABUTIL_STRLIST_H_ */