/* * Academic License - for use in teaching, academic research, and meeting * course requirements at degree granting institutions only. Not for * government, commercial, or other organizational use. * * fable_osi_emxutil.c * * Code generation for function 'fable_osi_emxutil' * */ /* Include files */ #include "fable_osi_emxutil.h" #include "fable_osi_types.h" #include "rt_nonfinite.h" #include /* Function Definitions */ void emxEnsureCapacity_real_T(const emlrtStack *sp, emxArray_real_T *emxArray, int32_T oldNumel, const emlrtRTEInfo *srcLocation) { int32_T i; int32_T newNumel; void *newData; if (oldNumel < 0) { oldNumel = 0; } newNumel = 1; for (i = 0; i < emxArray->numDimensions; i++) { newNumel = (int32_T)emlrtSizeMulR2012b((size_t)(uint32_T)newNumel, (size_t)(uint32_T)emxArray->size[i], srcLocation, (emlrtCTX)sp); } if (newNumel > emxArray->allocatedSize) { int32_T newCapacity; newCapacity = emxArray->allocatedSize; if (newCapacity < 16) { newCapacity = 16; } while (newCapacity < newNumel) { if (newCapacity > 1073741823) { newCapacity = MAX_int32_T; } else { newCapacity *= 2; } } newData = emlrtMallocMex((uint32_T)newCapacity * sizeof(real_T)); if (newData == NULL) { emlrtHeapAllocationErrorR2012b(srcLocation, (emlrtCTX)sp); } if (emxArray->data != NULL) { memcpy(newData, emxArray->data, sizeof(real_T) * (uint32_T)oldNumel); if (emxArray->canFreeData) { emlrtFreeMex(emxArray->data); } } emxArray->data = (real_T *)newData; emxArray->allocatedSize = newCapacity; emxArray->canFreeData = true; } } void emxFree_real_T(const emlrtStack *sp, emxArray_real_T **pEmxArray) { if (*pEmxArray != (emxArray_real_T *)NULL) { if (((*pEmxArray)->data != (real_T *)NULL) && (*pEmxArray)->canFreeData) { emlrtFreeMex((*pEmxArray)->data); } emlrtFreeMex((*pEmxArray)->size); emlrtRemoveHeapReference((emlrtCTX)sp, (void *)pEmxArray); emlrtFreeEmxArray(*pEmxArray); *pEmxArray = (emxArray_real_T *)NULL; } } void emxInit_real_T(const emlrtStack *sp, emxArray_real_T **pEmxArray, int32_T numDimensions, const emlrtRTEInfo *srcLocation) { emxArray_real_T *emxArray; int32_T i; *pEmxArray = (emxArray_real_T *)emlrtMallocEmxArray(sizeof(emxArray_real_T)); if ((void *)*pEmxArray == NULL) { emlrtHeapAllocationErrorR2012b(srcLocation, (emlrtCTX)sp); } emlrtPushHeapReferenceStackEmxArray((emlrtCTX)sp, true, (void *)pEmxArray, (void *)&emxFree_real_T, NULL, NULL, NULL); emxArray = *pEmxArray; emxArray->data = (real_T *)NULL; emxArray->numDimensions = numDimensions; emxArray->size = (int32_T *)emlrtMallocMex(sizeof(int32_T) * (uint32_T)numDimensions); if ((void *)emxArray->size == NULL) { emlrtHeapAllocationErrorR2012b(srcLocation, (emlrtCTX)sp); } emxArray->allocatedSize = 0; emxArray->canFreeData = true; for (i = 0; i < numDimensions; i++) { emxArray->size[i] = 0; } } /* End of code generation (fable_osi_emxutil.c) */