Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binc_application_set_char_updated_cb #55

Merged
merged 3 commits into from
Sep 22, 2024
Merged

binc_application_set_char_updated_cb #55

merged 3 commits into from
Sep 22, 2024

Conversation

abqjln
Copy link
Contributor

@abqjln abqjln commented Aug 30, 2024

Infrastructure is all there, but did not find this cb. Used to free temporary GByteArrays after binc_application_set_char_values.

Ex: when central/client requests a characteristic read , my server does
GByteArray *gbarray = g_byte_array_new();
g_byte_array_append( *gbarray, &value, 1);
binc_application_set_char_value(application, service_uuid, char_uuid, gbarray );
g_byte_array_free( gbarray, TRUE ); --> IF DO THIS Glib fails with g_atomic_ref_count_dec: assertion 'old_value > 0'

Putting the free in this cb frees only after the gbarray above is consumed.

@weliem
Copy link
Owner

weliem commented Aug 31, 2024

You shouldn't do g_byte_array_free( gbarray, TRUE );. The library will free it once it is not needed anymore.

@abqjln abqjln marked this pull request as ready for review September 1, 2024 12:11
@abqjln
Copy link
Contributor Author

abqjln commented Sep 1, 2024

Thank you!--that explains other issues I am having. My server has global structures with GByteArray elements to serve mullitple clients--the second client always fails, suspect due to having been freed. I will test. using local temporary GByteArrays.

@weliem weliem merged commit 5a47594 into weliem:main Sep 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants