macro LFDS710_HASH_A_GET_USER_STATE_FROM_STATE

From liblfds.org
Revision as of 21:04, 7 May 2016 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source File

└───liblfds710
    └───inc
        └───liblfds710
                lfds710_hash_addonly.h

Macro

#define LFDS710_HASH_A_GET_USER_STATE_FROM_STATE( hash_a_state )

Parameters

hash_a_state

An initialized struct lfds710_hash_a_state. Not a pointer to it - the struct itself.

Return Value

Returns a void *, the user_state argument from lfds710_hash_a_init_valid_on_current_logical_core.

Notes

The user state value can only be set the once, when the data structure instance is initialized.

As with all liblfds macros, the macro operates on the structure itself, not a pointer to it.

Example

#include "liblfds710.h"
#include <stdio.h>
#include <string.h>

void key_hash_function( void const *key, lfds710_uint_t *hash )
{
  assert( key != NULL );
  assert( hash != NULL );

  *hash = 0;

  // TRD : assuming key is 16 bytes in length
  LFDS710_HASH_A_HASH_FUNCTION( key, 16, *hash );

  return;
}

int main()
{
  char
    hash_a_name[64] = "Fable Of The Brown Ape";

  struct lfds710_btree_au_state
    baus_array[16];

  struct lfds710_hash_a_state
    has;

  void
    *user_state;

  lfds710_misc_init();

  lfds710_hash_a_init_valid_on_current_logical_core( &has, baus_array, 16, strcmp, key_hash_fuction, LFDS710_HASH_A_EXISTING_KEY_OVERWRITE, (void *) hash_a_name );

  user_state = LFDS710_HASH_A_GET_USER_STATE_FROM_STATE( has );

  printf( "hash_a name is \"%s\"\n", (char *) user_state );

  lfds710_hash_a_cleanup( &has, NULL );

  lfds710_misc_cleanup();

  return( EXIT_SUCCESS );
}

See Also