/* ************************************************************************ */ static void allocateMatrices (struct calculation_arguments* arguments) { uint64_t i, j; uint64_t const N = arguments->N; arguments->M = allocateMemory(arguments->num_matrices * (N + 1) * (N + 1) * sizeof(double)); arguments->Matrix = allocateMemory(arguments->num_matrices * sizeof(double**)); for (i = 0; i < arguments->num_matrices; i++) { arguments->Matrix[i] = allocateMemory((N + 1) * sizeof(double*)); for (j = 0; j <= N; j++) { arguments->Matrix[i][j] = arguments->M + (i * (N + 1) * (N + 1)) + (j * (N + 1)); } } }
void DbDiskInfo::updateRegularTable(SQLHSTMT sqlStmt,string& table, void* temp, void* lst) { vector<tlgpfs_disk_info_t*>* tempv = (vector<tlgpfs_disk_info_t*>*)temp; vector<tlgpfs_disk_info_t*>* lastv = (vector<tlgpfs_disk_info_t*>*)lst; tlgpfs_disk_info_t* last; tlgpfs_disk_info_t* tmp = tempv->front(); *tmp->change = CHANGE_NA; bool isNew = false; if(tempv->size() > 0 && lastv->size() == 0) { isNew = true; *tmp->change = CHANGE_ADDED; last = allocateMemory(); lastv->push_back(last); } else { last = lastv->front(); } if(isNew) initTable(sqlStmt, table); //init regular table bool anyChange = false; anyChange |= strcmp(tmp->node_name, last->node_name); anyChange |= strcmp(tmp->status, last->status); anyChange |= strcmp(tmp->availability, last->availability); anyChange |= strcmp(tmp->pool_name, last->pool_name); anyChange |= strcmp(tmp->vol_id, last->vol_id); anyChange |= strcmp(tmp->meta_data, last->meta_data); anyChange |= strcmp(tmp->data, last->data); anyChange |= strcmp(tmp->disk_wait, last->disk_wait); anyChange |= memcmp(tmp->total_space, last->total_space, sizeof( long long)); anyChange |= memcmp(tmp->full_blk_space, last->full_blk_space, sizeof( long long)); anyChange |= memcmp(tmp->sub_blk_space, last->sub_blk_space, sizeof( long long)); anyChange |= memcmp(tmp->fail_group_id, last->fail_group_id, sizeof( int)); anyChange |= memcmp(tmp->is_free, last->is_free,sizeof( int)); *tmp->change = anyChange?CHANGE_MODIFIED:CHANGE_NONE; //"status": "Unchanged" "Uninitialized" "NotInUse" "InUse" "Suspended" "BeingFormatted" "BeingAdded" "BeingEmptied" "BeingDeleted" "BeingDeleted-p" "ReferencesBeingRemoved" "BeingReplaced" "Replacement" "Unknown DiskConfigStatus" //"availability": "Unchanged" "OK" "Unavailable" "Recovering" "Unknown DiskAvailability" //only when "availability"=="OK" and "status" == "InUse", it's healthy if(*tmp->is_free == 1) // free disk's status is unknown *tmp->health = UNKNOWN; else if(strstr(tmp->availability,"OK") && strstr(tmp->status,"InUse")) *tmp->health = HEALTHY; else *tmp->health = UNHEALTHY; updateTable(sqlStmt,table,tmp); }
/// \param mesh Specifies the edit mesh to be converted. /// \note Any part and material information is lost in the conversion. void TriMesh::fromEditMesh(const EditTriMesh &mesh) { int i; // Make a copy of the mesh EditTriMesh tempMesh(mesh); // Make sure UV's are perperly set at the vertex level tempMesh.copyUvsIntoVertices(); // Optimize the order of the vertices for best cache performance. // This also discards unused vertices tempMesh.optimizeVertexOrder(); // Allocate memory allocateMemory(tempMesh.vertexCount(), tempMesh.triCount()); // Make sure we have something if (triCount < 1) { return; } // Convert vertices for (i = 0 ; i < vertexCount ; ++i) { const EditTriMesh::Vertex *s = &tempMesh.vertex(i); RenderVertex *d = &vertexList[i]; d->p = s->p; d->n = s->normal; d->u = s->u; d->v = s->v; } // Convert faces for (i = 0 ; i < triCount ; ++i) { const EditTriMesh::Tri *s = &tempMesh.tri(i); RenderTri *d = &triList[i]; d->index[0] = s->v[0].index; d->index[1] = s->v[1].index; d->index[2] = s->v[2].index; } // Make sure bounds are computed computeBoundingBox(); }
void LinearRegression::load(FILE *f) { int inputs1, outputs1; float version; int res = fscanf(f, "REGR %f %d %d\n", &version, &inputs1, &outputs1); if (res != 3) { printf("Error: unrecognized LinearRegression file. Expected header 'PERP <version> <inputs> <outputs>'."); exit(0); } if (version > VERSION) { printf("Error: loaded network is %1.2f, but code can only handle %1.2f to %1.2f.", version, MINVERSION, VERSION); exit(0); } if (VERSION >= 1.1) { char text[25]; res = fscanf(f, "%s\n", text); assert(res == 1); if (strcmp(text, "binary") == 0) useBinary = true; else //if (strcmp(text, "text") == 0) useBinary = false; } if ((inputs1 != inputs) || (outputs1 != outputs)) { freeMemory(); inputs = inputs1; outputs = outputs1; allocateMemory(); } for (int y = 0; y < outputs; y++) { for (int x = 0; x <= inputs; x++) { if (useBinary) { float shrunk; fread(&shrunk, sizeof(float), 1, f); //fread(&weight[y][x], sizeof(double), 1, f); little2machine(shrunk); weight[y][x] = shrunk; } else fscanf(f, "%le ", &weight[y][x]); } } }
void Toroid::init(){ vertCount = detail * segs; triFaceCount = vertCount*2; indicesCount = triFaceCount*3; allocateMemory(); createVertices(); createIndices(); createFaces(); createVertexNormals(); createCoords(); }
/* ************************************************************************ */ static void allocateMatrices (struct calculation_arguments* arguments) { uint64_t i, j; uint64_t const Y = arguments->N_plus_ghost_rows; uint64_t const X = arguments->N_global; arguments->M = allocateMemory(arguments->num_matrices * (Y + 1) * (X + 1) * sizeof(double)); arguments->Matrix = allocateMemory(arguments->num_matrices * sizeof(double**)); for (i = 0; i < arguments->num_matrices; i++) { arguments->Matrix[i] = allocateMemory((Y + 1) * sizeof(double*)); for (j = 0; j <= Y; j++) { arguments->Matrix[i][j] = arguments->M + (i * (Y + 1) * (X + 1)) + (j * (X + 1)); } } }
char * getLogString(char * procName , char * type, char * desc , HeapHandler hh) { char *logString = allocateMemory(hh , BUFFSIZE); SYSTEMTIME time; char inst[20]; DWORD pid = GetCurrentProcessId(); DWORD tid = GetCurrentThreadId(); GetLocalTime(&time); sprintf_s(inst, 20, "%02d:%02d:%02d.%03d", time.wHour,time.wMinute,time.wSecond,time.wMilliseconds); sprintf_s(logString, BUFFSIZE, "[%s][Proc: %s][ProcessID: %d][ThreadID: %d]:[Level: %s] %s\r\n",inst,procName,pid,tid,type,desc); return logString; }
CpuPtr_3D::CpuPtr_3D(unsigned int nx, unsigned int ny, unsigned int nz, unsigned int border, bool setToZero) : nx(nx), ny(ny), nz(nz), border(border), NX(nx+2*border), NY(ny+2*border), NZ(nz), xmin(0), ymin(0), xmax(1.0), ymax(1.0),time(0){ allocateMemory(); if (setToZero){ for (int k = 0; k < NZ; k++){ for (int j = 0; j < NY; j++){ for (int i = 0; i < NX; i++){ this->operator()(i-border,j-border, k) = 0.0; } } } } }
CompositionDBG::CompositionDBG(const int rId, const int rDimNumber, const int rNumPeaks,const ChangeType rT, \ const ComDBGFuncID rF, const double rChangingRatio,const bool rFlagDimChange,const bool rFlagNumPeakChange,\ const int peakNumChangeMode,const bool flagNoise, const bool flagTimelinkage):\ Problem(rId,rDimNumber,string(),1),RealDBG(rId,rDimNumber,rNumPeaks),mv_comBoundary(msc_numComFuns){ allocateMemory(m_numDim,m_numPeaks); m_name="DYN_CONT_CompositionDBG"; setComBoundary(); m_heightNormalizeSeverity=2000.; initialize(rT,rF,rChangingRatio,rFlagDimChange,rFlagNumPeakChange, peakNumChangeMode, flagNoise,flagTimelinkage); }
/* ************************************************************************ */ static void allocateMatrices (struct calculation_arguments* arguments) { int m, i; int const N = arguments->N; int const N_global = arguments->N_global; arguments->M = allocateMemory(arguments->num_matrices * (N + 1) * (N_global + 1) * sizeof(double)); arguments->Matrix = allocateMemory(arguments->num_matrices * sizeof(double**)); for (m = 0; m < arguments->num_matrices; m++) { arguments->Matrix[m] = allocateMemory((N + 1) * sizeof(double*)); for (i = 0; i < N + 1; i++) { arguments->Matrix[m][i] = arguments->M + (m * (N + 1) * (N_global + 1)) + (i * (N_global + 1)); } } }
char * concatString(char * a , char * b , HeapHandler hh){ char * c = NULL; int size = 0; if(a != NULL) size += (int)strlen(a); if(b != NULL) size += (int)strlen(b); c = allocateMemory(hh , size); sprintf(c , "%s%s" , a , b); return c; }
CPlayer::CPlayer( unsigned short whichPlayer, char gridSize) : m_whichPlayer(whichPlayer), m_gridSize(gridSize), m_gameGrid() { allocateMemory(); m_piecesLeft = MAXPIECE; for (int i = 0; i < SHIP_SIZE_ARRAYSIZE; i++) { m_ships[i].setName(i); m_ships[i].setBowLocation(cellToken); m_ships[i].setOrientation(CDirection::HORIZONTAL); m_ships[i].setPiecesLeft(shipSize[i]); } }
void JVector<T>::push_back(T) { size_t newSize = m_size + sizeof(T); if (newSize >= capacity) { CombinedPointer<T> newMemory = allocateMemory(newSize*2); for (uint i = 0u; i < m_size; ++i) { new (&newMemory.m_data[i]) T(m_data[i]); } m_memory = newMemory.m_memory; m_data = newMemory.m_data; } }
void AssemblerBuffer::reserve(uint32_t size) { if (size > allocatedSize) { void* oldAllocatedMemory = allocatedMemory; uint32_t oldAllocatedSize = allocatedSize; uint32_t alignment = getPageSize(); allocatedSize = std::max<uint32_t>(1024, std::max(2 * allocatedSize, ((size + alignment - 1) / alignment) * alignment)); allocatedMemory = allocateMemory(allocatedSize); if (oldAllocatedMemory) { memcpy(allocatedMemory, oldAllocatedMemory, usedSize); freeMemory(oldAllocatedMemory, oldAllocatedSize); } } }
/* ************************************************************************ */ static void allocateMatrices (struct calculation_arguments* arguments) { uint64_t i, j; uint64_t const N = arguments->N; //+ 2 rows for calculation uint64_t const numberOfRows= arguments->numberOfRows + 2; arguments->M = allocateMemory(arguments->num_matrices * numberOfRows * (N + 1) * sizeof(double)); arguments->Matrix = allocateMemory(arguments->num_matrices * sizeof(double**)); for (i = 0; i < arguments->num_matrices; i++) { arguments->Matrix[i] = allocateMemory(numberOfRows * sizeof(double*)); for (j = 0; j < numberOfRows; j++) { arguments->Matrix[i][j] = arguments->M + (i * numberOfRows * (N + 1)) + (j * (N + 1)); } } }
/* * ¦�� * top �������á��� * ߯Ի�� */ BOOL Nodeappendtail( Node** top , Node* add ) { Node* c; /*�������*/ Node* next; /*ޥ���������á�����*/ /*������NULL������������������*/ if( *top == NULL ){ *top = allocateMemory( sizeof( Node ) ); if( *top== NULL ) return FALSE; (*top)->next = NULL; /*���巴 ��*/ (*top)->size = add->size; /*Ӯ���綰*/ (*top)->val = add->val; /*���̼������������*/ return TRUE; } for( c = *top ; c->next ; c = c->next ); /* c���� ë������ */ next = allocateMemory( sizeof(Node) ); if( next == NULL )return FALSE; c->next = next; /* next���ëɬ������ */ next->next = NULL; /*���巴 ��*/ next->val = add->val; /*���̼������������*/ next->size = add->size; /*Ӯ���綰*/ return TRUE; }
//------------------------------------------------------------------------------ // copyData() -- copy member data //------------------------------------------------------------------------------ void SaH::copyData(const SaH& org, const bool cc) { if (cc) { // allocate memory before calling BaseClass::copyData() allocateMemory(ORDER); } BaseClass::copyData(org); sampleRate = org.sampleRate; time = org.time; stime = org.stime; initialize(); }
CpuPtr_2D &CpuPtr_2D::operator = (const CpuPtr_2D &rhs){ if(this == &rhs){ return *this; }else{ if (NX != rhs.NX || NY != rhs.NY){ this->~CpuPtr_2D(); nx = rhs.nx; ny = rhs.ny; border=rhs.border; NX = rhs.NX; NY = rhs.NY; allocateMemory(); } for (int i = 0; i < NX*NY; i++){ data[i]=rhs.data[i]; } } }
/* this is a non recursive function to insert into the array */ Node * insertNode(Node *treeHead, int value){ // initially if tree is empty if(treeHead == NULL){ treeHead = allocateMemory(value); return treeHead; } // if tree is not empty take the copy of root address to return Node * temp = treeHead; //loop till u get the itended position while(treeHead != NULL){ if(value < treeHead->value){ // if child empty insert he value and exit the loop if(!treeHead->lchild){ treeHead->lchild = allocateMemory(value); break; } treeHead = treeHead->lchild; } else if(value > treeHead->value){ // if child empty insert he value and exit the loop if(!treeHead->rchild){ treeHead->rchild = allocateMemory(value); break; } treeHead = treeHead->rchild; }// if the value == to the element do nothing else break; } return temp; }
/* * �����ͼ��年���� * ¦�� * top �������á��� * ߯Ի�� */ BOOL Nodeappendhead( Node** nowtop , Node* add ) { Node* newtop; /*ޥ������ ��*/ /*������NULL������������������*/ if( *nowtop == NULL ){ *nowtop = allocateMemory( sizeof( Node ) ); if( *nowtop == NULL ) return FALSE; (*nowtop)->next = NULL; /*���巴 ��*/ (*nowtop)->size = add->size; /*Ӯ���綰*/ (*nowtop)->val = add->val; /*���̼������������*/ return TRUE; } /* * ޥ�����á���ë������ */ newtop = allocateMemory( sizeof(Node) ); newtop->next = *nowtop; newtop->val = add->val; newtop->size = add->size; *nowtop = newtop; return TRUE; }
void *allocateInitializedMemory(unsigned size_in_bytes) { // Ask for what we will really receive unsigned size = (size_in_bytes + 3) / 4; void *ptr = allocateMemory(size * 4); if (ptr) { for (unsigned i = 0; i < size; i++) { ((int *)ptr)[i] = 0; } } return ptr; }
void initQ() { int i; WinEventQ *q = (WinEventQ *)allocateMemory(sizeof(WinEventQ)); q->num=W11_QSIZE-1; q->avail=0; q->next=0; q->count=0; q->dispatch=0; q->handler=NULL; for (i=0; i<W11_QSIZE; i++) { q->list[i].message=0; q->list[i].window = NULL; } wineventq = q; }
List createList( void (*aListingCriteria)(void *) , BOOL (*aEqualityCriteria)(void * , void *) , BOOL (*aSortingCriteria)(void * , void *) , HeapHandler hh){ List myList = allocateMemory(hh , sizeof(L)); myList->size = 0; myList->elements = NULL; myList->listingCriteria = aListingCriteria; myList->equalityCriteria = aEqualityCriteria; myList->sortingCriteria = aSortingCriteria; return myList; }
void DbPdiskInfo::updateRegularTable(SQLHSTMT sqlStmt,string& table, void* temp, void* lst) { vector<tlgpfs_pdisk_info_t*>* tempv = (vector<tlgpfs_pdisk_info_t*>*)temp; vector<tlgpfs_pdisk_info_t*>* lastv = (vector<tlgpfs_pdisk_info_t*>*)lst; tlgpfs_pdisk_info_t* last; tlgpfs_pdisk_info_t* tmp = tempv->front(); *tmp->change = CHANGE_NA; bool isNew = false; if(tempv->size() > 0 && lastv->size() == 0) { isNew = true; *tmp->change = CHANGE_ADDED; last = allocateMemory(); lastv->push_back(last); } else { last = lastv->front(); } if(isNew) initTable(sqlStmt, table); //init regular table bool anyChange = false; anyChange |= strcmp(tmp->pdisk_dev_path, last->pdisk_dev_path); anyChange |= strcmp(tmp->pdisk_state, last->pdisk_state); anyChange |= strcmp(tmp->pdisk_fru, last->pdisk_fru); anyChange |= strcmp(tmp->pdisk_location, last->pdisk_location); anyChange |= memcmp(tmp->pdisk_repl_prior, last->pdisk_repl_prior,sizeof( int)); anyChange |= memcmp(tmp->pdisk_free_space, last->pdisk_free_space,sizeof( unsigned long long)); *tmp->change = anyChange?CHANGE_MODIFIED:CHANGE_NONE; //"gpfsPdiskState": "ok" "formatting" "systemDrain" "adminDrain" "noData" "noVCD" "noRGD" "replace" "diagnosing" "init" "dead" //"missing" "suspended" "noPath" "abandoned" "readonly" "failing" "PTOW" //only when "gpfsPdiskState" == "systemDrain", "adminDrain", "readonly", "missing", "noPath", "PTOW", "diagnosing", "replace", "dead" or "failing", it's unhealthy if(strstr(tmp->pdisk_state, "systemDrain") || strstr(tmp->pdisk_state, "adminDrain") || strstr(tmp->pdisk_state, "readonly") || strstr(tmp->pdisk_state, "missing") || strstr(tmp->pdisk_state, "noPath") || strstr(tmp->pdisk_state, "PTOW") || strstr(tmp->pdisk_state, "diagnosing") || strstr(tmp->pdisk_state, "replace") || strstr(tmp->pdisk_state, "dead") || strstr(tmp->pdisk_state, "failing")) *tmp->health = UNHEALTHY; else *tmp->health = HEALTHY; updateTable(sqlStmt,table,tmp); }
SeriesIndex::SeriesIndex(uint64_t indexID, IndexManager *parent) { id = indexID; manager = parent; if(!this->init()){ shutdown(); } allocateMemory(); if(!loadSeries()){ shutdown(); } }
struct FileHandle* openFile(char* path, unsigned int mode) { unsigned int h = sys_open_file(path, mode); struct FileHandle* handle; if(!h) return 0; handle = allocateMemory(sizeof(struct FileHandle)); if(!handle) return 0; handle->handle = h; return handle; }
int checkIncomingMsg(char** opBuffer, u_long* bufLength) { int status; status = ioctlsocket(clientSocket, FIONREAD, bufLength); if (status == SOCKET_ERROR) return status; if (*bufLength <= 0) return status; *opBuffer = (void*)allocateMemory(*bufLength + 1); memset(*opBuffer, 0X0, *bufLength + 1); int bytesread = recv(clientSocket, *opBuffer, *bufLength, 0); return status; }
Buffer::Buffer(const char* filename) { // TODO Auto-generated constructor stub file = open(filename, O_RDONLY | O_SYNC | O_DIRECT); if (file == -1) { perror("Buffer open file"); exit(EXIT_FAILURE); } // init Buffer this->currentBuffer = 1; allocateMemory(); this->position = buffer1; this->nextBufferLoaded = false; // Fill first Buffer fillBuffer(1); }
void set_parameter(int npop, int ndim, int nobj, int narch) { F=0.5; CR=0.5; nObj=nobj; nDim=ndim; nPop=npop; nArch=narch; nSwm=nObj; maxIteration=(int)(nDim*1e4); // 30 S_SIZE=3; { S[0]=2; S[1]=3; S[2]=6; S[3]=10; S[4]=15; S[5]=30; } // 50 // S_SIZE=3; // { // S[0]=2; // S[1]=5; // S[2]=10; // S[3]=25; // S[4]=50; // S[5]=30; // } // archive arch_S_SIZE=2; { arch_S[0]=2; arch_S[1]=5; arch_S[2]=10; } allocateMemory(); setMPI(); #ifdef SUITE_PARALLEL EMO_TEST_SUITE::mpi_initialization(mpi_rank,mpi_size,nPop,nObj); #endif }
/* Creates new memory container object. * container - a memory container where to allocate * memory from. * parent - If it is null the memory container * will be the root node. * type - memory type * size - the size of MemoryContainer. In our case it is equal to * sizeof(MemokrySet). But if we in the future create a new * implementation class that derives from MemoryContainer, * we will have an opportunity to support it. * If container is null, we allocate memory from malloc * It can happen when we want to create the top memory context */ MemoryContainer memContCreate( void* self, MemoryContainer container, MemoryContainer parent, MemContType type, size_t size, char* name) { IMemContainerManager _ = (IMemContainerManager)self; IErrorLogger elog = _->errorLogger; MemoryContainer newCont; size_t neededSize = size + strlen(name) + 1; if (container != NULL) { newCont = (MemoryContainer)allocateMemory(self, container, neededSize); } else { ASSERT(elog, funcMalloc != NULL, NULL); newCont = (MemoryContainer)funcMalloc(neededSize); ASSERT(elog, newCont != NULL, NULL); } memset(newCont, 0, size); newCont->type = type; newCont->parent = NULL; newCont->childHead = NULL; newCont->next = NULL; newCont->isReset = True; newCont->name = ((char*)newCont) + size; strcpy(newCont->name, name); if (parent != NULL) { newCont->parent = parent; newCont->next = parent->childHead; parent->childHead = newCont; } return newCont; }