int heapInsert(PartialColoringHeap *heap, PartialColoring *pc) { const int timestep = pc->timestep; // create new heaps for new time step while (timestep >= heap->alloc_time_count) { int newsize = heap->alloc_time_count + heap->time_increment; heap->size = ReAlloc(heap->size, newsize*sizeof(int)); heap->alloc_size = ReAlloc(heap->alloc_size, newsize*sizeof(int)); heap->arrays = ReAlloc(heap->arrays, newsize*sizeof(PartialColoring**)); memset(heap->size + heap->alloc_time_count, 0, heap->time_increment*sizeof(int)); memset(heap->alloc_size + heap->alloc_time_count, 0, heap->time_increment*sizeof(int)); memset(heap->arrays + heap->alloc_time_count, 0, heap->time_increment*sizeof(PartialColoring **)); heap->alloc_time_count = newsize; } //printf("time: item %d heap %d\n", pc->timestep, heap->time_count); if (timestep+1>heap->time_count) { heap->time_count = timestep+1; } // increase heap size for new item if (heap->size[timestep] >= heap->alloc_size[timestep]) { int newsize = heap->alloc_size[timestep] + heap->array_increment; heap->arrays[timestep] = ReAlloc(heap->arrays[timestep], newsize * sizeof(PartialColoring*)); memset(heap->arrays[timestep] + heap->alloc_size[timestep], 0, heap->array_increment*sizeof(PartialColoring **)); heap->alloc_size[timestep] = newsize; } heap->arrays[timestep][heap->size[timestep]++] = pc; heapifyUp(heap->arrays[timestep], heap->size[timestep]); int found=0; for (int i=0;i<heap->size[timestep];i++) { if (heap->arrays[timestep][i]==pc) { found=1; break; } } assert(found); heap->item_count++; assert(heap->item_count>=0); return 1; }
void String::AddString(char *Add) { int la=strlen(Add); if (Length+la+1>Max) ReAlloc(Length+la+1); strcat(Str,Add); Length+=la; }
DATAHEAD* GetDataHead() { if (NULL != pFreeDataHead) { DATAHEAD* pTempDataHead = pFreeDataHead; pFreeDataHead = pFreeDataHead->pNext; return pTempDataHead; } if (ReAlloc()) { if (NULL != pFreeDataHead) { DATAHEAD* pTempDataHead = pFreeDataHead; pFreeDataHead = pFreeDataHead->pNext; return pTempDataHead; } } // ASSERT("GetDataHead??NULL?"); assert(false); return NULL; }
void String::Insert(char c,int p) { if (Length+2>Max) ReAlloc(Length+2); memmove(Str+p+1,Str+p,Length-p+1); Str[p]=c; Length+=1; }
void String::Pad(int Where,char Pad,int n) { if (Length+n>=Max) ReAlloc(Length+n+1); // +1 for null memmove(Str+Where+n,Str+Where,Length-Where+1); // +1 for null for (int i=0;i<n;i++) Str[Where+i]=Pad; Length+=n; }
void XYArray::SetAtGrow(int nIndex, XYItem& newVal) { if (nIndex >= AllocSize()) ReAlloc(AllocSize() * 2 + 1); (*this)[nIndex] = newVal; if (nIndex >= Size()) SetSize(nIndex + 1); }
// asummes p<len void String::Insert(char *s,int p) { int la=strlen(s); if (Length+la+1>Max) ReAlloc(Length+la+1); memmove(Str+p+la,Str+p,Length-p+1); strncpy(Str+p,s,la); Length+=la; }
int VECT::Remove(int pos, int ile) { if( ptr == 0 || pos >= Nelem() ) return 0; if( ile == 0L ) return 1; if( pos+ile < Nelem() ) memmove( ((char*)ptr) + pos*size, ((char*)ptr) + (pos + ile)*size, nbytes - (pos + ile)*size ); if( !ReAlloc(Nelem() - ile) ) return 0; return 1; }
void CStream::write(void *buf, UINT32 size) { if (!buf || !size) return; if (m_size + size > m_capacity) // 如果需要,扩展流缓冲区 ReAlloc(size); memcpy(m_stream+m_size, buf, size); // 写入 m_size += size; return; }
void* MT_DoubleBuffer::Request(U32 dwSize){ //if(GetCurrentThreadId()!=g_uiMainThreadId){ // OutputDebugStringA("More than One Thread Push Command!===============================================\n"); // //MessageBoxA(NULL,"More than One Thread Push Command!",NULL,NULL); //} U32& uiOffset = m_BufferOffset[m_uiWriteIndex]; if(uiOffset + dwSize > m_BufferSize[m_uiWriteIndex]){ ReAlloc(uiOffset + dwSize); } void* p = &m_Buffer[m_uiWriteIndex][uiOffset]; uiOffset += dwSize; return p; };
void CStream::write(void *buf, UINT32 amount, UINT32 size) { UINT32 total = amount*size; if (!buf || !total) return; if (m_size + total > m_capacity) ReAlloc(total); memcpy(m_stream+m_size, buf, total); m_size += total; return; }
STDMETHODIMP TinyMemoryStream::SetSize(ULARGE_INTEGER libNewSize) { UINT cbNew = (UINT)libNewSize.LowPart; if (cbNew > this->m_cbData) { if (cbNew > this->m_cbAlloc) { if (ReAlloc(cbNew) == NULL) return STG_E_INSUFFICIENTMEMORY; } ZeroMemory(this->m_pData + this->m_cbData, cbNew - this->m_cbData); } this->m_cbData = cbNew; return NOERROR; }
//-------------------------------------------------------------------- // @mfunc Set the offset into the file in bytes for a particular row. // If the Index is beyond current allocation, reallocation is attempted. // // @rdesc BOOLEAN value // @flag TRUE | Succeeded // @flag FALSE | Failed to Initialize // BOOL CFileIdx::SetIndex ( DBCOUNTITEM ulDex, //@parm IN | Row Index value size_t ulOffset //@parm IN | Offset of Row in the File ) { // Check index and realloc if beyond our current range if (m_ulDexCnt <= ulDex) if (FALSE == ReAlloc( ARRAY_INIT_SIZE )) return FALSE; m_rgDex[ulDex].ulOffset = ulOffset; m_rgDex[ulDex].bStatus = FALSE; return TRUE; }
void addIAL(IntArrayList *a, int i) { if (a->count==a->max) { //printf("increase max size from %d to %d\n", a->max, a->max+a->increment); a->max+=a->increment; a->p = ReAlloc(a->p, sizeof(int) * a->max); // the same thing //int *newp = MAlloc(sizeof(int*) * a->max); //memcpy(newp, a->p, sizeof(int*) * a->max); //Free(a->p); //a->p = newp; assert(a->p); } assertf(a->count < a->max, "count %d max %d", a->count, a->max); a->p[a->count++] = i; }
void Vector<T>::SetCountR(int n, const T& init) { Chk(); ASSERT(n >= 0); if(n == items) return; if(n < items) DestroyArray(vector + n, vector + items); else if(n > alloc) { T *prev = vector; ReAlloc(alloc + ntl_max(alloc, n - items)); DeepCopyConstructFill(vector + items, vector + n, init); RawFree(prev); } else DeepCopyConstructFill(vector + items, vector + n, init); items = n; }
/************************************************************************** * Str_SetPtrA [COMCTL32.234] * * Makes a copy of a string, allocating memory if necessary. * * PARAMS * lppDest [O] Pointer to destination string * lpSrc [I] Source string * * RETURNS * Success: TRUE * Failure: FALSE * * NOTES * Set lpSrc to NULL to free the memory allocated by a previous call * to this function. */ BOOL WINAPI Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc) { TRACE("(%p %p)\n", lppDest, lpSrc); if (lpSrc) { LPSTR ptr = ReAlloc (*lppDest, strlen (lpSrc) + 1); if (!ptr) return FALSE; strcpy (ptr, lpSrc); *lppDest = ptr; } else { Free (*lppDest); *lppDest = NULL; } return TRUE; }
/************************************************************************** * Str_SetPtrW [COMCTL32.236] * * See Str_SetPtrA. */ BOOL WINAPI Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc) { TRACE("(%p %s)\n", lppDest, debugstr_w(lpSrc)); if (lpSrc) { INT len = strlenW (lpSrc) + 1; LPWSTR ptr = ReAlloc (*lppDest, len * sizeof(WCHAR)); if (!ptr) return FALSE; strcpyW (ptr, lpSrc); *lppDest = ptr; } else { Free (*lppDest); *lppDest = NULL; } return TRUE; }
/************************************************************************** * Str_SetPtrWtoA [internal] * * Converts a unicode string to a multi byte string. * If the pointer to the destination buffer is NULL a buffer is allocated. * If the destination buffer is too small to keep the converted wide * string the destination buffer is reallocated. If the source pointer is * NULL, the destination buffer is freed. * * PARAMS * lppDest [I/O] pointer to a pointer to the destination buffer * lpSrc [I] pointer to a wide string * * RETURNS * TRUE: conversion successful * FALSE: error */ BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc) { TRACE("(%p %s)\n", lppDest, debugstr_w(lpSrc)); if (lpSrc) { INT len = WideCharToMultiByte(CP_ACP,0,lpSrc,-1,NULL,0,NULL,FALSE); LPSTR ptr = ReAlloc (*lppDest, len*sizeof(CHAR)); if (!ptr) return FALSE; WideCharToMultiByte(CP_ACP,0,lpSrc,-1,ptr,len,NULL,FALSE); *lppDest = ptr; } else { Free (*lppDest); *lppDest = NULL; } return TRUE; }
/************************************************************************** * Str_SetPtrAtoW [internal] * * Converts a multi byte string to a unicode string. * If the pointer to the destination buffer is NULL a buffer is allocated. * If the destination buffer is too small to keep the converted multi byte * string the destination buffer is reallocated. If the source pointer is * NULL, the destination buffer is freed. * * PARAMS * lppDest [I/O] pointer to a pointer to the destination buffer * lpSrc [I] pointer to a multi byte string * * RETURNS * TRUE: conversion successful * FALSE: error */ BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) { TRACE("(%p %s)\n", lppDest, lpSrc); if (lpSrc) { INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0); LPWSTR ptr = ReAlloc (*lppDest, len*sizeof(WCHAR)); if (!ptr) return FALSE; MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len); *lppDest = ptr; } else { Free (*lppDest); *lppDest = NULL; } return TRUE; }
//+--------------------------------------------------------------------------- // // Member: CString::Append // // Synopsis: Append chars to the end of the string, reallocating & updating // its length. // //---------------------------------------------------------------------------- HRESULT CString::Append(LPCTSTR pch, UINT uc) { HRESULT hr = S_OK; UINT ucOld, ucNew; BYTE* p; if(uc) { ucOld = Length(); ucNew = ucOld + uc; hr = ReAlloc(ucNew); if(hr) { goto Cleanup; } _tcsncpy(_pch+ucOld, pch, uc); ((TCHAR*)_pch)[ucNew] = 0; p = ((BYTE*)_pch - sizeof(UINT)); *(UINT*)p = ucNew * sizeof(TCHAR); } Cleanup: RRETURN(hr); }
STDMETHODIMP TinyMemoryStream::Write(void const *pv, ULONG cb, ULONG *pcbWritten) { if (!cb) { if (pcbWritten != NULL) *pcbWritten = 0; return NOERROR; } if ((this->m_iSeek + cb) > this->m_cbAlloc) { if (ReAlloc(this->m_iSeek + (UINT)cb + SIZEINCR) == NULL) return STG_E_INSUFFICIENTMEMORY; } ASSERT(this->m_pData); if (this->m_iSeek > this->m_cbData) { ZeroMemory(this->m_pData + this->m_cbData, this->m_iSeek - this->m_cbData); } CopyMemory(this->m_pData + this->m_iSeek, pv, cb); this->m_iSeek += (UINT)cb; if (this->m_iSeek > this->m_cbData) this->m_cbData = this->m_iSeek; if (pcbWritten != NULL) *pcbWritten = cb; return NOERROR; }
int VECT::Insert(int pos, void* buf, int ile) { if( !buf ) return 0; if ( pos*size > nbytes || ile < 0L ) return 0; if( !ptr && !size ) return 0; if( ile == 0L ) return 1; // if empty if( ptr == 0 && size != 0 && pos == 0L ) { if( !Alloc( ile, size ) ) return 0; memcpy( ptr, buf, ile*size ); return 1; } unsigned int oldnbytes = nbytes; if( !ReAlloc( Nelem() + ile ) ) return 0; if( pos*size < oldnbytes ) memmove( ((char*)ptr) + (pos+ile)*size, ((char*)ptr) + pos*size, oldnbytes-pos*size ); memcpy( ((char*)ptr) + pos*size, buf, ile*size ); return 1; }
PVOID AppendToBuffer(IN PVOID pBuffer, IN PSIZE_T pdwBufferSize, IN PVOID pData, IN SIZE_T dwDataSize) { PVOID pTmp; SIZE_T dwBufferSize; dwBufferSize = dwDataSize + *pdwBufferSize; if (pBuffer) pTmp = ReAlloc(0, pBuffer, dwBufferSize); else pTmp = Alloc(0, dwBufferSize); if (!pTmp) return NULL; memcpy((PVOID)((ULONG_PTR)pTmp + *pdwBufferSize), pData, dwDataSize); *pdwBufferSize = dwBufferSize; return pTmp; }
void BiVector<T>::Reserve(int n) { ASSERT(items >= 0); n += items; if(n > alloc) ReAlloc(n); }
void BiVector<T>::Shrink() { ASSERT(items >= 0); if(items < alloc) ReAlloc(items); }
void BiVector<T>::Add0() { ASSERT(items >= 0); if(items >= alloc) ReAlloc(ntl_max(2 * items, 4)); items++; }
// Get the instance list of virtual LAN card INSTANCE_LIST *GetInstanceList() { INSTANCE_LIST *n = ZeroMalloc(sizeof(INSTANCE_LIST)); // Enumeration char **ss = EnumVLan(VLAN_ADAPTER_NAME); if (ss == NULL) { // Failure n->NumInstance = 0; n->InstanceName = Malloc(0); return n; } else { UINT i, num; i = num = 0; while (true) { if (ss[i++] == NULL) { break; } num++; } i = 0; n->NumInstance = num; n->InstanceName = (char **)ZeroMalloc(sizeof(char *) * n->NumInstance); for (i = 0;i < num;i++) { char *s = ss[i] + StrLen(VLAN_ADAPTER_NAME) + StrLen(" - "); if (StrLen(ss[i]) > StrLen(VLAN_ADAPTER_NAME) + StrLen(" - ")) { n->InstanceName[i] = CopyStr(s); } } FreeEnumVLan(ss); } ss = EnumVLan(VLAN_ADAPTER_NAME_OLD); if (ss != NULL) { UINT i, num, j; i = num = 0; while (true) { if (ss[i++] == NULL) { break; } num++; } j = n->NumInstance; n->NumInstance += num; n->InstanceName = (char **)ReAlloc(n->InstanceName, sizeof(char) * n->NumInstance); for (i = 0;i < num;i++) { char *s = ss[i] + StrLen(VLAN_ADAPTER_NAME_OLD) + StrLen(" - "); if (StrLen(ss[i]) > StrLen(VLAN_ADAPTER_NAME_OLD) + StrLen(" - ")) { n->InstanceName[j] = CopyStr(s); } j++; } FreeEnumVLan(ss); } return n; }
BOOL CFrfr2:: InitIndex( FRFR2_IGA_HEADER *Header, PBYTE EntryBuffer, ULONG EntrySize, PBYTE FileNameBuffer, ULONG FileNameSize ) { ULONG Length, FileNameOffset, FileCount, MaxFileCount; ULONG BeginOffset; PWCHAR FileName; MY_FILE_ENTRY_BASE *pEntry, *pEntryBase; UNREFERENCED_PARAMETER(Header); FileCount = 0; MaxFileCount = 0x100; pEntryBase = (MY_FILE_ENTRY_BASE *)Alloc(MaxFileCount * sizeof(*m_Index.pEntry), HEAP_ZERO_MEMORY); if (pEntryBase == NULL) return FALSE; pEntry = pEntryBase; BeginOffset = file.GetCurrentPos64(); FileNameOffset = GetCompactInteger(EntryBuffer, &Length); for (LONG SizeOfEntry = EntrySize - Length; SizeOfEntry > 0; ++FileCount) { ULONG Offset2; LONG FileNameLength; pEntry->Offset.QuadPart = GetCompactInteger(EntryBuffer, &Length) + BeginOffset; SizeOfEntry -= Length; pEntry->Size.QuadPart = GetCompactInteger(EntryBuffer, &Length); SizeOfEntry -= Length; FileName = pEntry->FileName; Offset2 = GetCompactInteger(EntryBuffer, &Length); SizeOfEntry -= Length; FileNameLength = Offset2 - FileNameOffset; FileNameSize -= FileNameLength; if (SizeOfEntry < 0) FileNameLength += FileNameSize; for (; FileNameLength > 0; FileNameLength -= Length) { *FileName++ = GetCompactInteger(FileNameBuffer, &Length); } *FileName = 0; FileNameOffset = Offset2; if (FileCount == MaxFileCount) { MaxFileCount *= 2; pEntryBase = (MY_FILE_ENTRY_BASE *)ReAlloc(pEntryBase, MaxFileCount * sizeof(*m_Index.pEntry), HEAP_ZERO_MEMORY); if (pEntryBase == NULL) return FALSE; pEntry = pEntryBase + FileCount; } *(PULONG_PTR)&pEntry += m_Index.cbEntrySize; } m_Index.pEntry = pEntryBase; m_Index.FileCount.QuadPart = FileCount; m_Index.pEntry = (MY_FILE_ENTRY_BASE *)ReAlloc(m_Index.pEntry, m_Index.FileCount.LowPart * sizeof(*m_Index.pEntry)); return m_Index.pEntry != NULL; }
/*********************************************************************** * SYSLINK_Render * Renders the document in memory */ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect) { RECT rc; PDOC_ITEM Current; HGDIOBJ hOldFont; int x, y, LineHeight; SIZE szDoc; TEXTMETRICW tm; szDoc.cx = szDoc.cy = 0; rc = *pRect; rc.right -= SL_RIGHTMARGIN; rc.bottom -= SL_BOTTOMMARGIN; if(rc.right - SL_LEFTMARGIN < 0) rc.right = MAXLONG; if (rc.bottom - SL_TOPMARGIN < 0) rc.bottom = MAXLONG; hOldFont = SelectObject(hdc, infoPtr->Font); x = SL_LEFTMARGIN; y = SL_TOPMARGIN; GetTextMetricsW( hdc, &tm ); LineHeight = tm.tmHeight + tm.tmExternalLeading; for(Current = infoPtr->Items; Current != NULL; Current = Current->Next) { int n, nBlocks; LPWSTR tx; PDOC_TEXTBLOCK bl, cbl; INT nFit; SIZE szDim; int SkipChars = 0; if(Current->nText == 0) { continue; } tx = Current->Text; n = Current->nText; Free(Current->Blocks); Current->Blocks = NULL; bl = NULL; nBlocks = 0; if(Current->Type == slText) { SelectObject(hdc, infoPtr->Font); } else if(Current->Type == slLink) { SelectObject(hdc, infoPtr->LinkFont); } while(n > 0) { /* skip break characters unless they're the first of the doc item */ if(tx != Current->Text || x == SL_LEFTMARGIN) { if (n && *tx == '\n') { tx++; SkipChars++; n--; } while(n > 0 && (*tx) == infoPtr->BreakChar) { tx++; SkipChars++; n--; } } if((n == 0 && SkipChars != 0) || GetTextExtentExPointW(hdc, tx, n, rc.right - x, &nFit, NULL, &szDim)) { int LineLen = n; BOOL Wrap = FALSE; PDOC_TEXTBLOCK nbl; if(n != 0) { Wrap = SYSLINK_WrapLine(tx, infoPtr->BreakChar, x, &LineLen, nFit, &szDim); if(LineLen == 0) { /* move one line down, the word didn't fit into the line */ x = SL_LEFTMARGIN; y += LineHeight; continue; } if(LineLen != n) { if(!GetTextExtentExPointW(hdc, tx, LineLen, rc.right - x, NULL, NULL, &szDim)) { if(bl != NULL) { Free(bl); bl = NULL; nBlocks = 0; } break; } } } nbl = ReAlloc(bl, (nBlocks + 1) * sizeof(DOC_TEXTBLOCK)); if (nbl != NULL) { bl = nbl; nBlocks++; cbl = bl + nBlocks - 1; cbl->nChars = LineLen; cbl->nSkip = SkipChars; cbl->rc.left = x; cbl->rc.top = y; cbl->rc.right = x + szDim.cx; cbl->rc.bottom = y + szDim.cy; if (cbl->rc.right > szDoc.cx) szDoc.cx = cbl->rc.right; if (cbl->rc.bottom > szDoc.cy) szDoc.cy = cbl->rc.bottom; if(LineLen != 0) { x += szDim.cx; if(Wrap) { x = SL_LEFTMARGIN; y += LineHeight; } } } else { Free(bl); bl = NULL; nBlocks = 0; ERR("Failed to alloc DOC_TEXTBLOCK structure!\n"); break; } n -= LineLen; tx += LineLen; SkipChars = 0; } else { n--; } } if(nBlocks != 0) { Current->Blocks = bl; } } SelectObject(hdc, hOldFont); pRect->right = pRect->left + szDoc.cx; pRect->bottom = pRect->top + szDoc.cy; }
static bool Explore(count iregion, cSamples *samples, cint depth, cint flags) { #define SPLICE (flags & 1) #define HAVESAMPLES (flags & 2) TYPEDEFREGION; count n, dim, comp, maxcomp; Extrema extrema[NCOMP]; Result *r; real *x, *f; real halfvol, maxerr; Region *region; Bounds *bounds; Result *result; /* needed as of gcc 3.3 to make gcc correctly address region #@$&! */ sizeof(*region); if( SPLICE ) { if( nregions_ == size_ ) { size_ += CHUNKSIZE; ReAlloc(voidregion_, size_*sizeof(Region)); } VecCopy(region_[nregions_].bounds, region_[iregion].bounds); iregion = nregions_++; } region = ®ion_[iregion]; bounds = region->bounds; result = region->result; for( comp = 0; comp < ncomp_; ++comp ) { Extrema *e = &extrema[comp]; e->fmin = INFTY; e->fmax = -INFTY; e->xmin = e->xmax = NULL; } if( !HAVESAMPLES ) { real vol = 1; for( dim = 0; dim < ndim_; ++dim ) { cBounds *b = &bounds[dim]; vol *= b->upper - b->lower; } region->vol = vol; for( comp = 0; comp < ncomp_; ++comp ) { Result *r = &result[comp]; r->fmin = INFTY; r->fmax = -INFTY; } x = xgiven_; f = fgiven_; n = ngiven_; if( nextra_ ) n += SampleExtra(bounds); for( ; n; --n ) { for( dim = 0; dim < ndim_; ++dim ) { cBounds *b = &bounds[dim]; if( x[dim] < b->lower || x[dim] > b->upper ) goto skip; } for( comp = 0; comp < ncomp_; ++comp ) { Extrema *e = &extrema[comp]; creal y = f[comp]; if( y < e->fmin ) e->fmin = y, e->xmin = x; if( y > e->fmax ) e->fmax = y, e->xmax = x; } skip: x += ldxgiven_; f += ncomp_; } samples->sampler(samples, bounds, vol); } x = samples->x; f = samples->f; for( n = samples->n; n; --n ) { for( comp = 0; comp < ncomp_; ++comp ) { Extrema *e = &extrema[comp]; creal y = *f++; if( y < e->fmin ) e->fmin = y, e->xmin = x; if( y > e->fmax ) e->fmax = y, e->xmax = x; } x += ndim_; } neval_opt_ -= neval_; halfvol = .5*region->vol; maxerr = -INFTY; maxcomp = -1; for( comp = 0; comp < ncomp_; ++comp ) { Extrema *e = &extrema[comp]; Result *r = &result[comp]; real xtmp[NDIM], ftmp, err; if( e->xmin ) { /* not all NaNs */ selectedcomp_ = comp; sign_ = 1; VecCopy(xtmp, e->xmin); ftmp = FindMinimum(bounds, xtmp, e->fmin); if( ftmp < r->fmin ) { r->fmin = ftmp; VecCopy(r->xmin, xtmp); } sign_ = -1; VecCopy(xtmp, e->xmax); ftmp = -FindMinimum(bounds, xtmp, -e->fmax); if( ftmp > r->fmax ) { r->fmax = ftmp; VecCopy(r->xmax, xtmp); } } r->avg = samples->avg[comp]; r->err = samples->err[comp]; r->spread = halfvol*(r->fmax - r->fmin); err = r->spread/Max(fabs(r->avg), NOTZERO); if( err > maxerr ) { maxerr = err; maxcomp = comp; } } neval_opt_ += neval_; if( maxcomp == -1 ) { /* all NaNs */ region->depth = 0; return false; } region->cutcomp = maxcomp; r = ®ion->result[maxcomp]; if( halfvol*(r->fmin + r->fmax) > r->avg ) { region->fminor = r->fmin; region->fmajor = r->fmax; region->xmajor = r->xmax - (real *)region->result; } else { region->fminor = r->fmax; region->fmajor = r->fmin; region->xmajor = r->xmin - (real *)region->result; } region->depth = IDim(depth); if( !HAVESAMPLES ) { if( samples->weight*r->spread < r->err || r->spread < totals_[maxcomp].secondspread ) region->depth = 0; if( region->depth == 0 ) for( comp = 0; comp < ncomp_; ++comp ) totals_[comp].secondspread = Max(totals_[comp].secondspread, result[comp].spread); } if( region->depth ) Split(iregion, region->depth); return true; }