sms_queue_test: sanitize: clean up talloc contexts when done
To avoid sanitizer build failures, ensure that the talloc contexts are empty when done and free them. Separate the msgb context from the overall talloc context for clarity: if nested, the outer one would contain two blocks. Change the "sms_queue_test" context from 1 byte to 0 in order to get a size of zero in the end. Change-Id: If08ba48ab9c28bf3c2db4014837c1304cec04aaf
This commit is contained in:
parent
5900c84bd3
commit
0442ea22b8
|
@ -197,8 +197,10 @@ static struct log_info info = {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
talloc_ctx = talloc_named_const(NULL, 1, "sms_queue_test");
|
||||
msgb_talloc_ctx_init(talloc_ctx, 0);
|
||||
void *msgb_ctx;
|
||||
|
||||
talloc_ctx = talloc_named_const(NULL, 0, "sms_queue_test");
|
||||
msgb_ctx = msgb_talloc_ctx_init(NULL, 0);
|
||||
osmo_init_logging(&info);
|
||||
|
||||
OSMO_ASSERT(osmo_stderr_target);
|
||||
|
@ -211,5 +213,23 @@ int main(int argc, char **argv)
|
|||
test_next_sms();
|
||||
printf("Done\n");
|
||||
|
||||
if (talloc_total_blocks(msgb_ctx) != 1
|
||||
|| talloc_total_size(msgb_ctx) != 0) {
|
||||
talloc_report_full(msgb_ctx, stderr);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);
|
||||
OSMO_ASSERT(talloc_total_size(msgb_ctx) == 0);
|
||||
talloc_free(msgb_ctx);
|
||||
|
||||
if (talloc_total_blocks(talloc_ctx) != 1
|
||||
|| talloc_total_size(talloc_ctx) != 0)
|
||||
talloc_report_full(talloc_ctx, stderr);
|
||||
|
||||
OSMO_ASSERT(talloc_total_blocks(talloc_ctx) == 1);
|
||||
OSMO_ASSERT(talloc_total_size(talloc_ctx) == 0);
|
||||
talloc_free(talloc_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue