Skip to content

Commit

Permalink
c++:examples: Add an Os_Func ref check
Browse files Browse the repository at this point in the history
Just a demo of how to check that everything got freed.

Signed-off-by: Corey Minyard <[email protected]>
  • Loading branch information
cminyard committed Sep 6, 2024
1 parent 542aaaa commit eae2c63
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion c++/examples/telnet_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,17 @@ int main(int argc, char *argv[])
}

err = do_server(o, addr);

// This is not necessary, but can be used to make sure everything
// got freed properly. refcount on the os handler should be 3,
// one for the thread, one for the Addr, and one for the Os_Funcs.
if (o.get_refcount() != 3) {
cerr << "Invalid refcount: " << o.get_refcount() << endl;
return 1;
}
} catch (gensio_error &e) {
cerr << "gensio error: " << e.what() << endl;
}
return err;

return !!err;
}

0 comments on commit eae2c63

Please sign in to comment.