Skip to content
Snippets Groups Projects

Removed `goto fail` code with `unique_ptr`.

Merged Michael Whittaker requested to merge no_goto_fail into master

Previously, UDPTransport::SendMessageInternal dynamically allocated a char[] and used a goto fail to make sure that it was properly deleted. Something like:

    char *buf = new char[100];
    if (...) {
        ...
        goto fail;
    } else if (...) {
        ...
        goto fail;
    } else {
        ...
    }

fail:
     delete [] buf;
     return false;

Now, the array is stored in a unique_ptr so that it's properly deallocated when the function returns, without needing the goto fail.

Merge request reports

Merged by Irene Y ZhangIrene Y Zhang 7 years ago (Mar 1, 2018 8:40pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading