-
-
Save CitizenInsane/88376e034571550a3b82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mex.h" | |
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) | |
{ | |
mxArray* mx; | |
int ndim = 2; | |
int dims[] = {1, 1}; | |
const char *invalidFieldNames[] = { " ", "&;", "0lala", "n!" }; | |
int fieldCount = sizeof(invalidFieldNames)/sizeof(*invalidFieldNames); | |
// Arguments check | |
if (nrhs != 0) { mexErrMsgTxt("Must be called without input arguments."); return; } | |
if (nlhs > 1) { mexErrMsgTxt("Must be called with at most 1 output argument."); return; } | |
// Create a struct array with invalid field names | |
// NB: I know this is stupid, this is just to show that field names are not tested. | |
mx = mxCreateStructArray(ndim, dims, fieldCount, invalidFieldNames); | |
if (mx != NULL) | |
{ | |
mexPrintf("Oops was able to create field with invalid names and return this into matlab ...\n"); | |
if (nlhs > 0) { plhs[0] = mx; } | |
else { mxDestroyArray(mx); } | |
} | |
else | |
{ | |
mexErrMsgTxt("Cool, I'm not allowed to create struct with stupid field names.\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment