We have (for all intents and purposes) something similar to the following C++ code.
calc.h
#pragma once
extern "C" {
void doCalc(uint8_t** buffer);
}
calc.cpp
#include <cstdint>
#include "calc.h"
void doCalc(uint8_t** buffer) {
uint8_t lb[256];
for (int i = 0; i < 256; i++) {
lb[i] = i;
}
*buffer = new uint8_t[256];
std::memcpy(*buffer, lb, 256);
}
We need to call this method from Go, but unsure how to construct the buffer variable on the Go side to pass in (seeing as the length is unknown prior to calling - the 256 in the C++ function should be considered unknown).