char *BSckBufferGet(BSOCK_HANDLE hBSock, BSockLineBuffer *pBLB, int iTimeout, int *piLnLength) { int iLnLength = 0; int iCurrLength; int iGotNL; do { if (BSckGetString(hBSock, pBLB->pszBuffer + iLnLength, pBLB->iSize - 1 - iLnLength, iTimeout, &iCurrLength, &iGotNL) == NULL) return NULL; if (!iGotNL) { int iNewSize = 2 * pBLB->iSize + 1; char *pszBuffer = (char *) SysRealloc(pBLB->pszBuffer, (unsigned int) iNewSize); if (pszBuffer == NULL) return NULL; pBLB->pszBuffer = pszBuffer; pBLB->iSize = iNewSize; } iLnLength += iCurrLength; } while (!iGotNL); if (piLnLength != NULL) *piLnLength = iLnLength; return pBLB->pszBuffer; }
Matrix_t *MatNullSpace_(Matrix_t *mat, int flags) { long dim; Matrix_t *nsp; // check arguments if (!MatIsValid(mat)) { return NULL; } // allocate workspace nsp = MatAlloc(mat->Field,mat->Nor,mat->Nor); if (nsp == NULL) { return NULL; } nsp->PivotTable = NREALLOC(nsp->PivotTable,int,mat->Nor); if (nsp->PivotTable == NULL) { MatFree(nsp); return NULL; } // calculate the null-space FfSetNoc(mat->Noc); dim = znullsp(mat->Data,mat->Nor,nsp->PivotTable,nsp->Data,flags); if (dim == -1) { MatFree(nsp); return NULL; } if (flags) { SysFree(nsp->PivotTable); nsp->PivotTable = NULL; } // resize the result buffer to its actual size nsp->Nor = dim; nsp->Data = (PTR) SysRealloc(nsp->Data,nsp->RowSize * dim); return nsp; }