Back to index

lightning-sunbird  0.9+nobinonly
Functions
ckfwm.h File Reference
#include "nssbaset.h"
#include "nssckt.h"
#include "nssckfwt.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NSS_EXTERN nssCKFWHash * nssCKFWHash_Create (NSSCKFWInstance *fwInstance, NSSArena *arena, CK_RV *pError)
NSS_EXTERN void nssCKFWHash_Destroy (nssCKFWHash *hash)
NSS_EXTERN CK_RV nssCKFWHash_Add (nssCKFWHash *hash, const void *key, const void *value)
NSS_EXTERN void nssCKFWHash_Remove (nssCKFWHash *hash, const void *it)
NSS_EXTERN CK_ULONG nssCKFWHash_Count (nssCKFWHash *hash)
NSS_EXTERN CK_BBOOL nssCKFWHash_Exists (nssCKFWHash *hash, const void *it)
NSS_EXTERN voidnssCKFWHash_Lookup (nssCKFWHash *hash, const void *it)
NSS_EXTERN void nssCKFWHash_Iterate (nssCKFWHash *hash, nssCKFWHashIterator fcn, void *closure)

Function Documentation

NSS_EXTERN CK_RV nssCKFWHash_Add ( nssCKFWHash *  hash,
const void key,
const void value 
)

Definition at line 166 of file hash.c.

{
  CK_RV error = CKR_OK;
  PLHashEntry *he;

  error = nssCKFWMutex_Lock(hash->mutex);
  if( CKR_OK != error ) {
    return error;
  }
  
  he = PL_HashTableAdd(hash->plHashTable, key, (void *)value);
  if( (PLHashEntry *)NULL == he ) {
    error = CKR_HOST_MEMORY;
  } else {
    hash->count++;
  }

  (void)nssCKFWMutex_Unlock(hash->mutex);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWHash_Count ( nssCKFWHash *  hash)

Definition at line 224 of file hash.c.

{
  CK_ULONG count;

  if( CKR_OK != nssCKFWMutex_Lock(hash->mutex) ) {
    return (CK_ULONG)0;
  }

  count = hash->count;

  (void)nssCKFWMutex_Unlock(hash->mutex);

  return count;
}
NSS_EXTERN nssCKFWHash* nssCKFWHash_Create ( NSSCKFWInstance *  fwInstance,
NSSArena *  arena,
CK_RV pError 
)

Definition at line 98 of file hash.c.

{
  nssCKFWHash *rv;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (nssCKFWHash *)NULL;
  }

  if( PR_SUCCESS != nssArena_verifyPointer(arena) ) {
    *pError = CKR_ARGUMENTS_BAD;
    return (nssCKFWHash *)NULL;
  }
#endif /* NSSDEBUG */

  rv = nss_ZNEW(arena, nssCKFWHash);
  if( (nssCKFWHash *)NULL == rv ) {
    *pError = CKR_HOST_MEMORY;
    return (nssCKFWHash *)NULL;
  }

  rv->mutex = nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
  if( (NSSCKFWMutex *)NULL == rv->mutex ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    return (nssCKFWHash *)NULL;
  }

  rv->plHashTable = PL_NewHashTable(0, nss_ckfw_identity_hash, 
    PL_CompareValues, PL_CompareValues, &nssArenaHashAllocOps, arena);
  if( (PLHashTable *)NULL == rv->plHashTable ) {
    (void)nssCKFWMutex_Destroy(rv->mutex);
    (void)nss_ZFreeIf(rv);
    *pError = CKR_HOST_MEMORY;
    return (nssCKFWHash *)NULL;
  }

  rv->count = 0;

  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWHash_Destroy ( nssCKFWHash *  hash)

Definition at line 151 of file hash.c.

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWHash_Exists ( nssCKFWHash *  hash,
const void it 
)

Definition at line 247 of file hash.c.

{
  void *value;

  if( CKR_OK != nssCKFWMutex_Lock(hash->mutex) ) {
    return CK_FALSE;
  }

  value = PL_HashTableLookup(hash->plHashTable, it);

  (void)nssCKFWMutex_Unlock(hash->mutex);

  if( (void *)NULL == value ) {
    return CK_FALSE;
  } else {
    return CK_TRUE;
  }
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWHash_Iterate ( nssCKFWHash *  hash,
nssCKFWHashIterator  fcn,
void closure 
)

Definition at line 318 of file hash.c.

{
  struct arg_str as;
  as.fcn = fcn;
  as.closure = closure;

  if( CKR_OK != nssCKFWMutex_Lock(hash->mutex) ) {
    return;
  }

  PL_HashTableEnumerateEntries(hash->plHashTable, nss_ckfwhash_enumerator, &as);

  (void)nssCKFWMutex_Unlock(hash->mutex);

  return;
}

Here is the caller graph for this function:

NSS_EXTERN void* nssCKFWHash_Lookup ( nssCKFWHash *  hash,
const void it 
)

Definition at line 275 of file hash.c.

{
  void *rv;

  if( CKR_OK != nssCKFWMutex_Lock(hash->mutex) ) {
    return (void *)NULL;
  }

  rv = PL_HashTableLookup(hash->plHashTable, it);

  (void)nssCKFWMutex_Unlock(hash->mutex);

  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWHash_Remove ( nssCKFWHash *  hash,
const void it 
)

Definition at line 198 of file hash.c.

{
  PRBool found;

  if( CKR_OK != nssCKFWMutex_Lock(hash->mutex) ) {
    return;
  }

  found = PL_HashTableRemove(hash->plHashTable, it);
  if( found ) {
    hash->count--;
  }

  (void)nssCKFWMutex_Unlock(hash->mutex);
  return;
}

Here is the caller graph for this function: