Passing a dynamic array to XGDMatrixCreateFromMat

I can get XGDMatrixCreateFromMat to work if I pass it a static double array, but if I use a dynamic array the code runs but the features are all uninitialized.
Can someone steer me to a code example that uses a dynamically allocated array to call XGDMatrixCreateFromMat?

You should be able to write to the dynamically allocated array prior to calling XGDMatrixCreateFromMat. For example:

size_t ncol = 127;
float* row = new float[ncol];  // allocate a single row
std::memset(row, 0, ncol * sizeof(float));  // fill with zeros

float nan = std::numeric_limits<float>::quiet_NaN();

DMatrixHandle dmat;
int res = XGDMatrixCreateFromMat(row, 1, ncol, nan, &dmat);
if (res != 0) {
    throw std::runtime_error("XGDMatrixCreateFromMat() failed");