Difference between pages "r7.1.0:Macro LFDS710 LIST ASO GET START AND THEN NEXT" and "r7.1.0:Macro LFDS710 LIST ASO GET USER STATE FROM STATE"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
{{DISPLAYTITLE:macro LFDS710_LIST_ASO_GET_START_AND_THEN_NEXT}}
{{DISPLAYTITLE:macro LFDS710_LIST_ASO_GET_USER_STATE_FROM_STATE}}
==Source File==
==Source File==
  └───liblfds710
  └───liblfds710
Line 7: Line 7:


==Opaque Structures==
==Opaque Structures==
struct [[r7.1.0:struct lfds710_list_aso_element|lfds710_list_aso_element]];
  struct [[r7.1.0:struct lfds710_list_aso_state|lfds710_list_aso_state]];
  struct [[r7.1.0:struct lfds710_list_aso_state|lfds710_list_aso_state]];


==Macro==
==Macro==
  #define LFDS710_LIST_ASO_GET_START_AND_THEN_NEXT( list_aso_state, pointer_to_list_aso_element )
  #define LFDS710_LIST_ASO_GET_USER_STATE_FROM_STATE( list_aso_state )


==Parameters==
==Parameters==
''list_aso_state''
''list_aso_state''
: A ''struct lfds710_list_aso_state''.  Not a pointer to it - the struct itself.
: An initialized ''struct lfds710_list_aso_state''.  Not a pointer to it - the struct itself.
 
''pointer_to_list_aso_element''
: A pointer to ''struct lfds710_list_aso_element''.  This is and only is a pointer - it's not the address of an actual, allocated struct.


==Return Value==
==Return Value==
If ''pointer_to_list_aso_element'' is NULL, returns (and sets ''pointer_to_list_aso_element'' to be the same value) a ''struct lfds710_list_aso_element *'' to the first element in the list.
Returns a ''void *'', the ''user_state'' argument from ''[[r7.1.0:function lfds710_list_aso_init_valid_on_current_logical_core|lfds710_list_aso_init_valid_on_current_logical_core]]''.


If ''pointer_to_list_aso_element'' is not NULL, returns (and sets ''pointer_to_list_aso_element'' to be the same value) a ''struct lfds710_list_aso_element *'' to the element after the list element ''*pointer_to_list_aso_element''.
==Notes==
The user state value can only be set the once, when the data structure instance is initialized.


==Notes==
As with all ''liblfds'' macros, the macro operates on the structure itself, not a pointer to it.
This is a convenience macro, expected use is in the conditional part of while loops.  If the ''pointer_to_list_aso_element'' argument is NULL, then the macro returns (and sets the element pointer to be) the first element; if it is non-NULL (and then mustt be a pointer to an element in the list), then the macro returns (and sets the element pointer to be)  the next element in the list, eventully returning (and setting the element pointer to be) NULL, which causes the while loop to finish.


==Example==
==Example==
Coming soonNo, really! (Written 29th Dec 2015).
#include "liblfds710.h"
#include <stdio.h>
#include <string.h>
int main()
{
  char
    list_aso_name[64] = "Bring It On";
  struct lfds710_list_aso_state
    laso;
  void
    *user_state;
  lfds710_misc_library_init_valid_on_current_logical_core();
   
  lfds710_list_aso_init_valid_on_current_logical_core( &laso, strcmp, LFDS710_LIST_ASO_EXISTING_KEY_FAIL, (void *) list_aso_name );
   
  user_state = LFDS710_LIST_ASO_GET_USER_STATE_FROM_STATE( laso );
  printf( "list_aso name is \"%s\"\n", (char *) user_state );
  lfds710_list_aso_cleanup( &laso, NULL );
  lfds710_misc_library_cleanup();
  return( EXIT_SUCCESS );
}


==See Also==
==See Also==
* [[r7.1.0:List (add-only, singly-linked, ordered)|List (add-only, singly-linked, ordered)]]
* [[r7.1.0:List (add-only, singly-linked, ordered)|List (add-only, singly-linked, ordered)]]

Latest revision as of 08:21, 8 May 2016

Source File

└───liblfds710
    └───inc
        └───liblfds710
                lfds710_list_addonly_singlylinked_ordered.h

Opaque Structures

struct lfds710_list_aso_state;

Macro

#define LFDS710_LIST_ASO_GET_USER_STATE_FROM_STATE( list_aso_state )

Parameters

list_aso_state

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

Return Value

Returns a void *, the user_state argument from lfds710_list_aso_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>

int main()
{
  char
    list_aso_name[64] = "Bring It On";

  struct lfds710_list_aso_state
    laso;

  void
    *user_state;

  lfds710_misc_library_init_valid_on_current_logical_core();

  lfds710_list_aso_init_valid_on_current_logical_core( &laso, strcmp, LFDS710_LIST_ASO_EXISTING_KEY_FAIL, (void *) list_aso_name );

  user_state = LFDS710_LIST_ASO_GET_USER_STATE_FROM_STATE( laso );

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

  lfds710_list_aso_cleanup( &laso, NULL );

  lfds710_misc_library_cleanup();

  return( EXIT_SUCCESS );
}

See Also