U32 len; /* length */
/*cm_hash_c_001.main_23 : Fix for TRACE5 feature crash due to missing TRC MACRO*/
- TRC2(cmHashFuncAnyKey);
/* Set up the internal state */
len = keyLen; /* key length */
a = 0x9e3779b9; /* a = b = the golden ratio; an arbitrary value */
else
*idx = (U16) (c % hashListCp->nmbBins);
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncAnyKey */
{
U32 sum; /* Sum of octets for hash function */
- TRC2(cmHashFuncU32Mod);
/* keyLen is marked Unused to remove compilation
* warnings. */
else
*idx = (U16) (sum % hashListCp->nmbBins);
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncU32Mod () */
U32 secondU32 = 0; /* Second U32 prepared for higher 4 octets */
U32 sum; /* Sum of the above 2 octets to get the index */
- TRC2(cmHashFuncBCD8);
/* keyLen is marked Unused to remove compilation
* warnings. */
else
*idx = (U16) (sum % hashListCp->nmbBins);
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncBCD8 () */
/*
U16 cntr; /* Index */
U32 sum; /* Sum of octets for hash function */
- TRC2(cmHashFuncString)
sum = 0;
else
*idx = (U16) (sum % hashListCp->nmbBins);
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncString () */
{
U32 sum; /* sum of key string octets */
- TRC2(cmHashFuncDefault);
/* add all bytes of the key */
sum = 0;
else
*idx = (U16) (sum % hashListCp->nmbBins);
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncDefault */
U32 prod; /* (constant multiplier * key) */
U8 shift; /* Bits to be shifted to get index */
- TRC2(cmHashFuncMult24);
UNUSED(keyLen);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if (hashListCp->binBitMask == CM_HASH_NOBITMASK)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
prod = CM_HASH_MULT24_CONST * *((U32 *)key);
shift = CM_HASH_MULT24_BITPOS - hashListCp->nmbBinBits;
*idx = ((U16) (prod & (hashListCp->binBitMask << shift))) >> shift;
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncMult24 */
#endif
{
- TRC2(cmHashFuncConId);
/* switch based on the length of the key */
switch (keyLen)
break;
default:
- RETVALUE(RFAILED);
+ return RFAILED;
}
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncConId */
U16 *idx; /* index to return */
#endif
{
- TRC2(cmHashFuncDirIdx);
UNUSED(hashListCp);
UNUSED(keyLen);
*idx = *((U16 *) key);
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashFuncDirIdx */
\f
U16 keyLen2; /* length of second key string */
#endif
{
- TRC2(cmHashMatchKey);
/* compare key lengths */
if (keyLen1 != keyLen2)
- RETVALUE(RFAILED);
+ return RFAILED;
/* compare key strings */
- RETVALUE(cmMemcmp(key1, key2, (PTR) keyLen1));
+ return (cmMemcmp(key1, key2, (PTR) keyLen1));
} /* end of cmHashMatchKey */
\f
CmListEnt *newEntry; /* new entry to add */
#endif
{
- TRC2(cmListInsert);
newEntry->next = oldEntry->next;
newEntry->prev = oldEntry;
oldEntry->next = newEntry;
(newEntry->next)->prev = newEntry;
- RETVALUE(ROK);
+ return ROK;
} /* end of cmListInsert */
\f
CmListEnt *entry; /* entry to delete */
#endif
{
- TRC2(cmListDelete);
if (entry == NULLP)
- RETVALUE(RFAILED);
+ return RFAILED;
if (entry->prev != NULLP)
(entry->prev)->next = entry->next;
if (entry->next != NULLP)
(entry->next)->prev = entry->prev;
- RETVALUE(ROK);
+ return ROK;
} /* end of cmListDelete */
*
*/
#ifdef ANSI
-PUBLIC S16 cmHashListInit
+S16 cmHashListInit
(
CmHashListCp *hashListCp, /* hash list to initialize */
U16 nmbBins, /* number of hash list bins */
Pool pool /* memory pool to allocate bins */
)
#else
-PUBLIC S16 cmHashListInit(hashListCp, nmbBins, offset, dupFlg, keyType, region, pool)
+S16 cmHashListInit(hashListCp, nmbBins, offset, dupFlg, keyType, region, pool)
CmHashListCp *hashListCp; /* hash list to initialize */
U16 nmbBins; /* number of hash list bins */
U16 offset; /* offset of CmHashListEnt in entries */
CmListBinEnt *hl;
#endif
- TRC2(cmHashListInit);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if (hashListCp == NULLP)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* initialize control point fields */
case CM_HASH_KEYTYPE_MULT24:
/* return failure if number of bins is not a power of 2 */
if (((nmbBins) & (nmbBins - 1)) != 0)
- RETVALUE (RFAILED);
+ return (RFAILED);
hashListCp->hashFunc = cmHashFuncMult24;
break;
#ifndef CM_MT_HASH_BIN
if (SGetSBuf(region, pool, (Data **) &hashListCp->hl,
(Size) (nmbBins * sizeof(CmListEnt))) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
#else
if (SGetSBuf(region, pool, (Data **) &hashListCp->hl,
(Size) (nmbBins * sizeof(CmListBinEnt))) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* initialize bin pointers */
}
}
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashListInit */
\f
*
*/
#ifdef ANSI
-PUBLIC S16 cmHashListDeinit
+S16 cmHashListDeinit
(
CmHashListCp *hashListCp /* hash list to deinitialize */
)
#else
-PUBLIC S16 cmHashListDeinit(hashListCp)
+S16 cmHashListDeinit(hashListCp)
CmHashListCp *hashListCp; /* hash list to deinitialize */
#endif
{
- TRC2(cmHashListDeinit);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if (hashListCp == NULLP)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* deallocate memory for bins */
hashListCp->keyType = CM_HASH_KEYTYPE_DEF;
hashListCp->hashFunc = NULLP;
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashListDeinit */
\f
*/
#ifdef ANSI
-PUBLIC S16 cmHashListInsert
+S16 cmHashListInsert
(
CmHashListCp *hashListCp, /* hash list to add to */
PTR entry, /* entry to add */
U16 keyLen /* length of key */
)
#else
-PUBLIC S16 cmHashListInsert(hashListCp, entry, key, keyLen)
+S16 cmHashListInsert(hashListCp, entry, key, keyLen)
CmHashListCp *hashListCp; /* hash list to add to */
PTR entry; /* entry to add */
U8 *key; /* pointer to key */
PTR dupEntry; /* pointer to entry with duplicate key */
U16 idx; /* index for insertion into hash list */
- TRC2(cmHashListInsert);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if ((hashListCp == NULLP) || (entry == NULLP) ||
(key == NULLP) || (keyLen == 0))
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* check for duplicates */
{
/* no duplicates allowed, check if key already exists */
if (cmHashListFind(hashListCp, key, keyLen, 0, &dupEntry) == ROK)
- RETVALUE(ROKDUP);
+ return (ROKDUP);
}
/* get pointer to hash list entry header */
/* compute index for insertion */
if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
hashListEnt->hashVal = idx;
hashListCp->hl[idx].nmbEnt++;
#endif /* #ifndef CM_MT_HASH_BIN */
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashListInsert */
\f
*/
#ifdef ANSI
-PUBLIC S16 cmHashListDelete
+S16 cmHashListDelete
(
CmHashListCp *hashListCp, /* hash list to delete from */
PTR entry /* entry to delete */
)
#else
-PUBLIC S16 cmHashListDelete(hashListCp, entry)
+S16 cmHashListDelete(hashListCp, entry)
CmHashListCp *hashListCp; /* hash list to delete from */
PTR entry; /* entry to delete */
#endif
U16 idx; /* index for selecting the right hash list bin */
#endif
- TRC2(cmHashListDelete);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if ((hashListCp == NULLP) || (entry == NULLP))
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* get pointer to hash list entry header */
/* check if entry is already deleted if yes then return OK */
if((hashListEnt->list.next == NULLP) ||
(hashListEnt->list.prev == NULLP))
- RETVALUE(ROK);
+ return ROK;
#ifdef CM_MT_HASH_BIN
/* compute index for insertion */
if ((*hashListCp->hashFunc)(hashListCp, hashListEnt->key,
hashListEnt->keyLen, &idx) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif /* #ifdef CM_MT_HASH_BIN */
/* delete entry from list */
hashListCp->hl[idx].nmbEnt--;
#endif /* #ifndef CM_MT_HASH_BIN */
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashListDelete */
\f
*/
#ifdef ANSI
-PUBLIC S16 cmHashListFind
+S16 cmHashListFind
(
CmHashListCp *hashListCp, /* hash list to search */
U8 *key, /* pointer to key */
PTR *entry /* entry to be returned */
)
#else
-PUBLIC S16 cmHashListFind(hashListCp, key, keyLen, seqNmb, entry)
+S16 cmHashListFind(hashListCp, key, keyLen, seqNmb, entry)
CmHashListCp *hashListCp; /* hash list to search */
U8 *key; /* pointer to key */
U16 keyLen; /* length of key */
U16 i; /* counter for sequence number */
U16 idx; /* index for insertion into hash list */
- TRC2(cmHashListFind);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if ((hashListCp == NULLP) || (key == NULLP) ||
(keyLen == 0) || (entry == NULLP))
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* compute hash table index */
if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
/* search this bin for exact key match */
hashListBin = &hashListCp->hl[idx];
/* check for duplicates */
if (!hashListCp->dupFlg)
- RETVALUE(ROK);
+ return ROK;
/* for duplicate key, check sequence number */
if (i++ == seqNmb)
- RETVALUE(ROK);
+ return ROK;
}
/* go to next entry */
}
/* no matching key found */
- RETVALUE(RFAILED);
+ return RFAILED;
} /* end of cmHashListFind */
\f
*
*/
#ifdef ANSI
-PUBLIC S16 cmHashListGetNext
+S16 cmHashListGetNext
(
CmHashListCp *hashListCp, /* hash list to get from */
PTR prevEnt, /* previous entry */
PTR *entry /* entry to be returned */
)
#else
-PUBLIC S16 cmHashListGetNext(hashListCp, prevEnt, entry)
+S16 cmHashListGetNext(hashListCp, prevEnt, entry)
CmHashListCp *hashListCp; /* hash list to get from */
PTR prevEnt; /* previous entry */
PTR *entry; /* entry to be returned */
CmHashListEnt *prevListEnt; /* previous hash list entry pointer */
U16 i; /* hash list counter */
- TRC2(cmHashListGetNext);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if ((hashListCp == NULLP) || (entry == NULLP))
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* check if need to get first entry */
/* requested entry is in nxtEnt */
*entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset);
- RETVALUE(ROK);
+ return ROK;
}
/* no more entries */
- RETVALUE(ROKDNA);
+ return (ROKDNA);
}
/* use previous entry to find next entry */
/* found next entry */
*entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset);
- RETVALUE(ROK);
+ return ROK;
}
/* no more entries in this bin, go to next bin, check if more bins */
}
/* no more entries */
- RETVALUE(ROKDNA);
+ return (ROKDNA);
} /* end of cmHashListGetNext */
#ifdef CM_MT_HASH_BIN
*
*/
#ifdef ANSI
-PUBLIC S16 cmHashListBinGetNextEntry
+S16 cmHashListBinGetNextEntry
(
CmHashListCp *hashListCp, /* hash list to get from */
U16 binIdx, /* Bin Index to retreive the entry */
PTR *entry /* entry to be returned */
)
#else
-PUBLIC S16 cmHashListBinGetNextEntry(hashListCp, binIdx, prevEnt, entry)
+S16 cmHashListBinGetNextEntry(hashListCp, binIdx, prevEnt, entry)
CmHashListCp *hashListCp; /* hash list to get from */
U16 binIdx; /* Bin Index to retreive the entry */
PTR prevEnt; /* previous entry */
CmHashListEnt *hashListEnt; /* temporary hash list entry pointer */
CmHashListEnt *prevListEnt; /* previous hash list entry pointer */
- TRC2(cmHashListBinGetNextEntry);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if ((hashListCp == NULLP) || (entry == NULLP))
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* check if need to get first entry */
/* requested entry is in nxtEnt */
*entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset);
- RETVALUE(ROK);
+ return ROK;
}
/* no more entries */
- RETVALUE(ROKDNA);
+ return (ROKDNA);
}
/* use previous entry to find next entry */
/* found next entry */
*entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset);
- RETVALUE(ROK);
+ return ROK;
}
/* no more entries */
- RETVALUE(ROKDNA);
+ return (ROKDNA);
} /* end of cmHashListBinGetNextEntry */
#endif
*
*/
#ifdef ANSI
-PUBLIC S16 cmHashListQuery
+S16 cmHashListQuery
(
CmHashListCp *hashListCp, /* hash list to query */
U8 queryType, /* type of query */
U16 *result /* result of query */
)
#else
-PUBLIC S16 cmHashListQuery(hashListCp, queryType, result)
+S16 cmHashListQuery(hashListCp, queryType, result)
CmHashListCp *hashListCp; /* hash list to query */
U8 queryType; /* type of query */
U16 *result; /* result of query */
U8 i;
#endif
- TRC2(cmHashListQuery);
/* deal with queries that do not need hashListCp */
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if (result == NULLP)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* respond depending on query type */
#else
*result = (U16) sizeof(CmListBinEnt);
#endif
- RETVALUE(ROK);
+ return ROK;
}
/* deal with queries that do need hashListCp */
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if (hashListCp == NULLP)
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
/* respond depending on query type */
*result += hashListCp->hl[i].nmbEnt;
}
#endif
- RETVALUE(ROK);
+ return ROK;
case CM_HASH_QUERYTYPE_BINS: /* number of bins */
*result = (U16) hashListCp->nmbBins;
- RETVALUE(ROK);
+ return ROK;
case CM_HASH_QUERYTYPE_OFFSET: /* offset of CmHashListEnt in entries */
*result = (U16) hashListCp->offset;
- RETVALUE(ROK);
+ return ROK;
case CM_HASH_QUERYTYPE_DUPFLG: /* allow duplicate keys */
*result = (U16) hashListCp->dupFlg;
- RETVALUE(ROK);
+ return ROK;
case CM_HASH_QUERYTYPE_KEYTYPE: /* key type for selecting hash functions */
*result = (U16) hashListCp->keyType;
- RETVALUE(ROK);
+ return ROK;
default: /* process other query types */
break;
}
/* illegal query type */
- RETVALUE(RFAILED);
+ return RFAILED;
} /* end of cmHashListQuery */
#ifdef HASH_OPEN_ADDRESSING
*/
#ifdef ANSI
-PUBLIC S16 cmHashListOAInsert
+S16 cmHashListOAInsert
(
CmHashListCp *hashListCp, /* hash table to add to */
PTR entry, /* entry to add */
U16 keyLen /* length of key */
)
#else
-PUBLIC S16 cmHashListOAInsert(hashListCp, entry, key, keyLen)
+S16 cmHashListOAInsert(hashListCp, entry, key, keyLen)
CmHashListCp *hashListCp; /* hash table to add to */
PTR entry; /* entry to add */
U8 *key; /* pointer to key */
/* cm_hash_c_001.main_21. Modify. Compilation Issue resolved. */
U16 nmbEnt;
- TRC2(cmHashListOAInsert);
#if (ERRCLASS & ERRCLS_DEBUG)
/* error check on parameters */
if ((hashListCp == NULLP) || (entry == NULLP) ||
(key == NULLP) || (keyLen == 0))
- RETVALUE(RFAILED);
+ return RFAILED;
#endif
#ifndef CM_MT_HASH_BIN
#endif
/* check if table is full */
if (hashListCp->nmbBins == nmbEnt)
- RETVALUE(ROUTRES);
+ return (ROUTRES);
/* get pointer to hash list entry header */
hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset);
/* compute index for insertion */
if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
/*
* find an empty bin
/* insert into list */
if (cmListInsert(hashBin->prev, &hashListEnt->list) != ROK)
- RETVALUE(RFAILED);
+ return RFAILED;
hashListEnt->hashVal = idx;
hashBin->nmbEnt++;
#endif
- RETVALUE(ROK);
+ return ROK;
} /* end of cmHashListOAInsert */