Skip to content
Snippets Groups Projects
Commit 4ceab25d authored by Michael Whittaker's avatar Michael Whittaker
Browse files

Removed `goto fail` code with `unique_ptr`.

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

```c++
    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.
parent c56a1c7d
No related branches found
No related tags found
1 merge request!3Removed `goto fail` code with `unique_ptr`.
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment