Skip to content

Commit

Permalink
docs: make usage of LDPersistence_Init clearer (#460)
Browse files Browse the repository at this point in the history
This commit provides better documentation for how to initialize the
`LDPersistence` struct.

The existing docs were ambiguous as to when the call should be made. If
you call _after_ setting custom pointers, then the custom pointers will
be wiped out.
  • Loading branch information
cwaldren-ld authored Oct 22, 2024
1 parent 1babc17 commit 0305481
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,25 @@ struct LDPersistence {
};

/**
* Initializes a custom persistence implementation. Must be called before
* passing a custom implementation into configuration.
* @param backend Implementation to initialize.
* Initializes an instance of LDPersistence with default function pointers,
* additionally setting UserData to NULL.
*
* This must be called after declaring the struct, but before setting any
* custom function pointers.
*
* Example:
* @code
* struct LDPersistence customPersistence;
* LDPersistence_Init(&customPersistence);
*
* customPersistence.SetFn = my_set_function;
* customPersistence.RemoveFn = my_remove_function;
* customPersistence.ReadFn = my_read_function;
* customPersistence.FreeFn = my_free_read_function;
* customPersistence.UserData = my_user_data_ptr;
* @endcode
*
* @param LDPersistence to initialize.
*/
LD_EXPORT(void)
LDPersistence_Init(struct LDPersistence* implementation);
Expand Down

0 comments on commit 0305481

Please sign in to comment.