mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Update LLVM from stable upstream (#1653)
Replace CheckedMalloc with upstream safe_malloc.
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "HttpCameraImpl.h"
|
||||
|
||||
#include <wpi/MemAlloc.h>
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/TCPConnector.h>
|
||||
#include <wpi/memory.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Handle.h"
|
||||
@@ -611,7 +611,7 @@ void CS_SetHttpCameraUrls(CS_Source source, const char** urls, int count,
|
||||
char** CS_GetHttpCameraUrls(CS_Source source, int* count, CS_Status* status) {
|
||||
auto urls = cs::GetHttpCameraUrls(source, status);
|
||||
char** out =
|
||||
static_cast<char**>(wpi::CheckedMalloc(urls.size() * sizeof(char*)));
|
||||
static_cast<char**>(wpi::safe_malloc(urls.size() * sizeof(char*)));
|
||||
*count = urls.size();
|
||||
for (size_t i = 0; i < urls.size(); ++i) out[i] = cs::ConvertToC(urls[i]);
|
||||
return out;
|
||||
|
||||
@@ -17,7 +17,7 @@ static void ConvertToC(CS_UsbCameraInfo* out, const UsbCameraInfo& in) {
|
||||
out->path = ConvertToC(in.path);
|
||||
out->name = ConvertToC(in.name);
|
||||
out->otherPaths = static_cast<char**>(
|
||||
wpi::CheckedMalloc(in.otherPaths.size() * sizeof(char*)));
|
||||
wpi::safe_malloc(in.otherPaths.size() * sizeof(char*)));
|
||||
out->otherPathsCount = in.otherPaths.size();
|
||||
for (size_t i = 0; i < in.otherPaths.size(); ++i)
|
||||
out->otherPaths[i] = cs::ConvertToC(in.otherPaths[i]);
|
||||
@@ -50,7 +50,7 @@ CS_UsbCameraInfo* CS_GetUsbCameraInfo(CS_Source source, CS_Status* status) {
|
||||
auto info = cs::GetUsbCameraInfo(source, status);
|
||||
if (*status != CS_OK) return nullptr;
|
||||
CS_UsbCameraInfo* out = static_cast<CS_UsbCameraInfo*>(
|
||||
wpi::CheckedMalloc(sizeof(CS_UsbCameraInfo)));
|
||||
wpi::safe_malloc(sizeof(CS_UsbCameraInfo)));
|
||||
ConvertToC(out, info);
|
||||
return out;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ CS_UsbCameraInfo* CS_GetUsbCameraInfo(CS_Source source, CS_Status* status) {
|
||||
CS_UsbCameraInfo* CS_EnumerateUsbCameras(int* count, CS_Status* status) {
|
||||
auto cameras = cs::EnumerateUsbCameras(status);
|
||||
CS_UsbCameraInfo* out = static_cast<CS_UsbCameraInfo*>(
|
||||
wpi::CheckedMalloc(cameras.size() * sizeof(CS_UsbCameraInfo)));
|
||||
wpi::safe_malloc(cameras.size() * sizeof(CS_UsbCameraInfo)));
|
||||
*count = cameras.size();
|
||||
for (size_t i = 0; i < cameras.size(); ++i) ConvertToC(&out[i], cameras[i]);
|
||||
return out;
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <wpi/MemAlloc.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/memory.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
inline char* ConvertToC(wpi::StringRef in) {
|
||||
char* out = static_cast<char*>(wpi::CheckedMalloc(in.size() + 1));
|
||||
char* out = static_cast<char*>(wpi::safe_malloc(in.size() + 1));
|
||||
std::memmove(out, in.data(), in.size());
|
||||
out[in.size()] = '\0';
|
||||
return out;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <wpi/MemAlloc.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/memory.h>
|
||||
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
@@ -70,7 +70,7 @@ char** CS_GetEnumPropertyChoices(CS_Property property, int* count,
|
||||
CS_Status* status) {
|
||||
auto choices = cs::GetEnumPropertyChoices(property, status);
|
||||
char** out =
|
||||
static_cast<char**>(wpi::CheckedMalloc(choices.size() * sizeof(char*)));
|
||||
static_cast<char**>(wpi::safe_malloc(choices.size() * sizeof(char*)));
|
||||
*count = choices.size();
|
||||
for (size_t i = 0; i < choices.size(); ++i)
|
||||
out[i] = cs::ConvertToC(choices[i]);
|
||||
@@ -123,7 +123,7 @@ CS_Property* CS_EnumerateSourceProperties(CS_Source source, int* count,
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = cs::EnumerateSourceProperties(source, buf, status);
|
||||
CS_Property* out = static_cast<CS_Property*>(
|
||||
wpi::CheckedMalloc(vec.size() * sizeof(CS_Property)));
|
||||
wpi::safe_malloc(vec.size() * sizeof(CS_Property)));
|
||||
*count = vec.size();
|
||||
std::copy(vec.begin(), vec.end(), out);
|
||||
return out;
|
||||
@@ -183,7 +183,7 @@ CS_VideoMode* CS_EnumerateSourceVideoModes(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
auto vec = cs::EnumerateSourceVideoModes(source, status);
|
||||
CS_VideoMode* out = static_cast<CS_VideoMode*>(
|
||||
wpi::CheckedMalloc(vec.size() * sizeof(CS_VideoMode)));
|
||||
wpi::safe_malloc(vec.size() * sizeof(CS_VideoMode)));
|
||||
*count = vec.size();
|
||||
std::copy(vec.begin(), vec.end(), out);
|
||||
return out;
|
||||
@@ -193,8 +193,8 @@ CS_Sink* CS_EnumerateSourceSinks(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
wpi::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = cs::EnumerateSourceSinks(source, buf, status);
|
||||
CS_Sink* sinks = static_cast<CS_Sink*>(
|
||||
wpi::CheckedMalloc(handles.size() * sizeof(CS_Sink)));
|
||||
CS_Sink* sinks =
|
||||
static_cast<CS_Sink*>(wpi::safe_malloc(handles.size() * sizeof(CS_Sink)));
|
||||
*count = handles.size();
|
||||
std::copy(handles.begin(), handles.end(), sinks);
|
||||
return sinks;
|
||||
@@ -271,7 +271,7 @@ CS_Property* CS_EnumerateSinkProperties(CS_Sink sink, int* count,
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = cs::EnumerateSinkProperties(sink, buf, status);
|
||||
CS_Property* out = static_cast<CS_Property*>(
|
||||
wpi::CheckedMalloc(vec.size() * sizeof(CS_Property)));
|
||||
wpi::safe_malloc(vec.size() * sizeof(CS_Property)));
|
||||
*count = vec.size();
|
||||
std::copy(vec.begin(), vec.end(), out);
|
||||
return out;
|
||||
@@ -372,7 +372,7 @@ CS_Source* CS_EnumerateSources(int* count, CS_Status* status) {
|
||||
wpi::SmallVector<CS_Source, 32> buf;
|
||||
auto handles = cs::EnumerateSourceHandles(buf, status);
|
||||
CS_Source* sources = static_cast<CS_Source*>(
|
||||
wpi::CheckedMalloc(handles.size() * sizeof(CS_Source)));
|
||||
wpi::safe_malloc(handles.size() * sizeof(CS_Source)));
|
||||
*count = handles.size();
|
||||
std::copy(handles.begin(), handles.end(), sources);
|
||||
return sources;
|
||||
@@ -390,8 +390,8 @@ void CS_ReleaseEnumeratedSources(CS_Source* sources, int count) {
|
||||
CS_Sink* CS_EnumerateSinks(int* count, CS_Status* status) {
|
||||
wpi::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = cs::EnumerateSinkHandles(buf, status);
|
||||
CS_Sink* sinks = static_cast<CS_Sink*>(
|
||||
wpi::CheckedMalloc(handles.size() * sizeof(CS_Sink)));
|
||||
CS_Sink* sinks =
|
||||
static_cast<CS_Sink*>(wpi::safe_malloc(handles.size() * sizeof(CS_Sink)));
|
||||
*count = handles.size();
|
||||
std::copy(handles.begin(), handles.end(), sinks);
|
||||
return sinks;
|
||||
@@ -426,8 +426,8 @@ char* CS_GetHostname() { return cs::ConvertToC(cs::GetHostname()); }
|
||||
|
||||
char** CS_GetNetworkInterfaces(int* count) {
|
||||
auto interfaces = cs::GetNetworkInterfaces();
|
||||
char** out = static_cast<char**>(
|
||||
wpi::CheckedMalloc(interfaces.size() * sizeof(char*)));
|
||||
char** out =
|
||||
static_cast<char**>(wpi::safe_malloc(interfaces.size() * sizeof(char*)));
|
||||
*count = interfaces.size();
|
||||
for (size_t i = 0; i < interfaces.size(); ++i)
|
||||
out[i] = cs::ConvertToC(interfaces[i]);
|
||||
|
||||
Reference in New Issue
Block a user