mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update LLVM from stable upstream (#1653)
Replace CheckedMalloc with upstream safe_malloc.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <wpi/memory.h>
|
||||
#include <wpi/MemAlloc.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Value_internal.h"
|
||||
@@ -123,7 +123,7 @@ void nt::ConvertToC(const Value& in, NT_Value* out) {
|
||||
case NT_BOOLEAN_ARRAY: {
|
||||
auto v = in.GetBooleanArray();
|
||||
out->data.arr_boolean.arr =
|
||||
static_cast<int*>(wpi::CheckedMalloc(v.size() * sizeof(int)));
|
||||
static_cast<int*>(wpi::safe_malloc(v.size() * sizeof(int)));
|
||||
out->data.arr_boolean.size = v.size();
|
||||
std::copy(v.begin(), v.end(), out->data.arr_boolean.arr);
|
||||
break;
|
||||
@@ -131,7 +131,7 @@ void nt::ConvertToC(const Value& in, NT_Value* out) {
|
||||
case NT_DOUBLE_ARRAY: {
|
||||
auto v = in.GetDoubleArray();
|
||||
out->data.arr_double.arr =
|
||||
static_cast<double*>(wpi::CheckedMalloc(v.size() * sizeof(double)));
|
||||
static_cast<double*>(wpi::safe_malloc(v.size() * sizeof(double)));
|
||||
out->data.arr_double.size = v.size();
|
||||
std::copy(v.begin(), v.end(), out->data.arr_double.arr);
|
||||
break;
|
||||
@@ -139,7 +139,7 @@ void nt::ConvertToC(const Value& in, NT_Value* out) {
|
||||
case NT_STRING_ARRAY: {
|
||||
auto v = in.GetStringArray();
|
||||
out->data.arr_string.arr = static_cast<NT_String*>(
|
||||
wpi::CheckedMalloc(v.size() * sizeof(NT_String)));
|
||||
wpi::safe_malloc(v.size() * sizeof(NT_String)));
|
||||
for (size_t i = 0; i < v.size(); ++i)
|
||||
ConvertToC(v[i], &out->data.arr_string.arr[i]);
|
||||
out->data.arr_string.size = v.size();
|
||||
@@ -154,7 +154,7 @@ void nt::ConvertToC(const Value& in, NT_Value* out) {
|
||||
|
||||
void nt::ConvertToC(wpi::StringRef in, NT_String* out) {
|
||||
out->len = in.size();
|
||||
out->str = static_cast<char*>(wpi::CheckedMalloc(in.size() + 1));
|
||||
out->str = static_cast<char*>(wpi::safe_malloc(in.size() + 1));
|
||||
std::memcpy(out->str, in.data(), in.size());
|
||||
out->str[in.size()] = '\0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user