GIFHASH.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "render.h"
00008 #undef OK
00009 #include "giflib.h"
00010 #include "gifhash.h"
00011
00012 #ifdef _SUNSTYLE
00013 static long KeyItem();
00014 #else
00015 static long KeyItem(unsigned long Item);
00016 #endif
00017
00018
00019
00020
00021 #ifdef _SUNSTYLE
00022 GifHashTableType *_InitHashTable(){
00023 #else
00024 GifHashTableType *_InitHashTable(void){
00025 #endif
00026 GifHashTableType *HashTable;
00027 if ((HashTable = (GifHashTableType *) X__Malloc(sizeof(GifHashTableType)))
00028 == NULL) return NULL;
00029 _ClearHashTable(HashTable);
00030 return HashTable;
00031 }
00032
00033
00034
00035
00036
00037 #ifdef _SUNSTYLE
00038 void _ClearHashTable(HashTable) GifHashTableType *HashTable; {
00039 #else
00040 void _ClearHashTable(GifHashTableType *HashTable){
00041 #endif
00042 memset(HashTable -> HTable, 0xFF, HT_SIZE * sizeof(long));
00043 }
00044
00045
00046
00047
00048
00049 #ifdef _SUNSTYLE
00050 void _InsertHashTable(HashTable,Key,Code) GifHashTableType *HashTable;
00051 unsigned long Key; long Code; {
00052 #else
00053 void _InsertHashTable(GifHashTableType *HashTable,
00054 unsigned long Key, long Code){
00055 #endif
00056 long HKey = KeyItem(Key);
00057 unsigned long *HTable = HashTable -> HTable;
00058
00059
00060 while (HT_GET_KEY(HTable[HKey]) != 0xFFFFFL) {
00061 HKey = (HKey + 1) & HT_KEY_MASK;
00062 }
00063 HTable[HKey] = HT_PUT_KEY(Key) | HT_PUT_CODE(Code);
00064 }
00065
00066
00067
00068
00069
00070 #ifdef _SUNSTYLE
00071 long _ExistsHashTable(HashTable,Key) GifHashTableType *HashTable;
00072 unsigned long Key; {
00073 #else
00074 long _ExistsHashTable(GifHashTableType *HashTable, unsigned long Key){
00075 #endif
00076 long HKey = KeyItem(Key);
00077 unsigned long *HTable = HashTable -> HTable, HTKey;
00078
00079
00080 while ((HTKey = HT_GET_KEY(HTable[HKey])) != 0xFFFFFL) {
00081 if (Key == HTKey) return (long)(HT_GET_CODE(HTable[HKey]));
00082 HKey = (HKey + 1) & HT_KEY_MASK;
00083 }
00084
00085 return -1;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095 #ifdef _SUNSTYLE
00096 static long KeyItem(Item) unsigned long Item; {
00097 #else
00098 static long KeyItem(unsigned long Item){
00099 #endif
00100 return (long)(((Item >> 12) ^ Item) & HT_KEY_MASK);
00101 }
00102