#include <NeuralNetworks.h>
+#include <new>
+
#include "model.h"
#include "compilation.h"
model->release(internal);
- ANeuralNetworksCompilation *compilation_ptr = new ANeuralNetworksCompilation(internal);
- if (compilation_ptr == nullptr)
+ *compilation = new (std::nothrow) ANeuralNetworksCompilation(internal);
+ if (*compilation == nullptr)
{
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- *compilation = compilation_ptr;
return ANEURALNETWORKS_NO_ERROR;
}
#include <NeuralNetworks.h>
+#include <new>
+
#include "compilation.h"
#include "execution.h"
#include "event.h"
compilation->publish(plan);
- ANeuralNetworksExecution *execution_ptr = new ANeuralNetworksExecution{plan};
- if (execution_ptr == nullptr)
+ *execution = new (std::nothrow) ANeuralNetworksExecution{plan};
+ if (*execution == nullptr)
{
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- *execution = execution_ptr;
return ANEURALNETWORKS_NO_ERROR;
}
}
// TODO: Handle event
- ANeuralNetworksEvent *event_ptr = new ANeuralNetworksEvent{};
- if (event_ptr == nullptr)
+ *event = new (std::nothrow) ANeuralNetworksEvent{};
+ if (*event == nullptr)
{
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- *event = event_ptr;
const auto &plan = execution->plan();
const auto &model = plan.model();
#include <NeuralNetworks.h>
#include <sys/mman.h>
+#include <new>
#include "memory.h"
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
- ANeuralNetworksMemory *memory_ptr = new ANeuralNetworksMemory{size, protect, fd, offset};
- if (memory_ptr == nullptr)
+ *memory = new (std::nothrow) ANeuralNetworksMemory{size, protect, fd, offset};
+ if (*memory == nullptr)
{
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- *memory = memory_ptr;
return ANEURALNETWORKS_NO_ERROR;
}
#include <cassert>
#include <stdexcept>
+#include <new>
#include "model.h"
#include "memory.h"
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
- ANeuralNetworksModel *model_ptr = new ANeuralNetworksModel{};
-
- if (model_ptr == nullptr)
+ *model = new (std::nothrow) ANeuralNetworksModel{};
+ if (*model == nullptr)
{
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- *model = model_ptr;
-
return ANEURALNETWORKS_NO_ERROR;
}