Function anjay_delete_with_core_persistence

Function Documentation

int anjay_delete_with_core_persistence(anjay_t *anjay, avs_stream_t *out_stream)

Persists the core library state into the out_stream and then deletes the Anjay instance but does NOT deregister from any LwM2M Servers.

NOTE: Anjay is deleted from memory even if the persistence operation fails (in which case any persisted data shall be considered invalid). It should generally not be a problem though, because in the worst case scenario the client will later need to perform full re-register and reconnection (at DTLS layer as well, if secure connection is used).

NOTE: It shall be called before freeing LwM2M Objects registered within the anjay object.

NOTE: The anjay pointer is invalidated during the call to this function. If Anjay is compiled with thread safety enabled, all the intermediary cleanup code is properly synchronized, but you should still make sure that no other thread is able to access the anjay object before calling this function, to avoid its usage after free.

Parameters:
  • anjay – Anjay object to persist and then delete from memory.

  • out_stream – Stream where persisted data shall be stored.

Returns:

0 if persistence operation suceeded, negative value otherwise. On failure, the out_stream contents are undefined, and some data may have been written to the backend storage. The partially-filled persistence data should not be used with anjay_new_from_core_persistence.