[wpiutil] uv Handle: Use malloc/free instead of new/delete (#3325)

This avoids asan warnings for deleting a different pointer type.
This commit is contained in:
Peter Johnson
2021-05-01 07:04:14 -07:00
committed by GitHub
parent 365f5449ca
commit f99f62bee4
4 changed files with 9 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
#include <uv.h>
#include <cstdlib>
#include <functional>
#include <memory>
#include <utility>
@@ -288,7 +289,7 @@ class HandleImpl : public Handle {
}
protected:
HandleImpl() : Handle{reinterpret_cast<uv_handle_t*>(new U)} {}
HandleImpl() : Handle{static_cast<uv_handle_t*>(std::malloc(sizeof(U)))} {}
};
} // namespace wpi::uv

View File

@@ -7,6 +7,7 @@
#include <uv.h>
#include <cstdlib>
#include <functional>
#include <memory>
@@ -143,7 +144,8 @@ class NetworkStreamImpl : public NetworkStream {
}
protected:
NetworkStreamImpl() : NetworkStream{reinterpret_cast<uv_stream_t*>(new U)} {}
NetworkStreamImpl()
: NetworkStream{static_cast<uv_stream_t*>(std::malloc(sizeof(U)))} {}
};
} // namespace wpi::uv

View File

@@ -7,6 +7,7 @@
#include <uv.h>
#include <cstdlib>
#include <functional>
#include <initializer_list>
#include <memory>
@@ -292,7 +293,7 @@ class StreamImpl : public Stream {
}
protected:
StreamImpl() : Stream{reinterpret_cast<uv_stream_t*>(new U)} {}
StreamImpl() : Stream{static_cast<uv_stream_t*>(std::malloc(sizeof(U)))} {}
};
} // namespace wpi::uv