Пример #1
0
MatrixMxN<Scalar>::MatrixMxN(unsigned int rows, unsigned int cols, Scalar *entries)
{
    allocMemory(rows,cols);
    for(unsigned int i = 0; i < rows; ++i)
        for(unsigned int j = 0; j < cols; ++j)
            (*this)(i,j) = entries[i*cols+j];
}
MultiLayerNet *MultiLayerFactory::createFromInfo(const BuildInfo &newInfo) {
    currentMode = 1;
    MultiLayerNet *bpNewNet = 0;
    nnInfo = newInfo;
    bpNewNet = allocMemory(bpNewNet);
    return bpNewNet;
}
Пример #3
0
MatrixMxN<Scalar>::MatrixMxN(unsigned int rows, unsigned int cols, Scalar value)
{
    allocMemory(rows,cols);
    for(unsigned int i = 0; i < rows; ++i)
        for(unsigned int j = 0; j < cols; ++j)
            (*this)(i,j) = value;
}
Пример #4
0
void parseAndLoadArgs(unsigned int procID,char *string)
{
    struct taskStruct *t;
    t=getTask(procID);
    if(t==0)
        return;
    t->argv=(char **)(t->dataSegmentBase+t->dataSegmentSize);
    /*
        unsigned int tmp=t->dataSegmentBase+t->dataSegmentSize+4;
     allocMemory(procID,t->argv+user_start,5+4+1000);
         memcpyToTask( &tmp, 4,user_start+t->dataSegmentBase+t->dataSegmentSize,procID );
         memcpyToTask( "test\0", 5,user_start+t->dataSegmentBase+t->dataSegmentSize+4,procID );
        t->dataSegmentSize+=4+5;
    */
    int n=parseArgsNum(string);
    t->argc=n;
    unsigned int *array=kmalloc(4*n);
    char *buffer=kmalloc(strlen(string)+1);
    unsigned int c,i=0,d=0;
    char apice=0;
    for(c=0; c<strlen(string); c++)
    {
        if(string[c]==' ')
            break;
    }
    if(c==strlen(string) || c+1==strlen(string))
    {
        t->argc=0;
        kfree(array);
        kfree(buffer);
        return;
    }
    for(; c<strlen(string); c++)
    {
        if(string[c]=='\'')
        {
            apice=!apice;
            continue;
        }
        if(string[c]==' ' && !apice)
        {
            array[i]=t->dataSegmentBase+t->dataSegmentSize+(4*n)+d+1;
            i++;
        }
        else
        {
            buffer[d]=string[c];
            buffer[d+1]=0;
        }
        d++;
    }

    allocMemory(procID,user_start+t->dataSegmentBase+t->dataSegmentSize,(4*n)+d+1);
    memcpyToTask( (char*)array, 4*n,(char*)(user_start+t->dataSegmentBase+t->dataSegmentSize),procID );
    memcpyToTask( buffer, d+1,(char*)(user_start+t->dataSegmentBase+t->dataSegmentSize+(4*n)),procID );
    t->dataSegmentSize+=(4*n)+d+1;

    kfree(array);
    kfree(buffer);
}
Пример #5
0
Error_t CFft::init( int iBlockLength, int iZeroPadFactor, WindowFunction_t eWindow /*= kWindowHann*/, Windowing_t eWindowing /*= kPreWindow*/ )
{
    Error_t  rErr = kNoError;

    // sanity check
    if (!CUtil::isPowOf2(iBlockLength) || iZeroPadFactor <= 0 || !CUtil::isPowOf2(iBlockLength*iZeroPadFactor))
        return kFunctionInvalidArgsError;

    // clean up
    reset();

    m_iDataLength   = iBlockLength;
    m_iFftLength    = iBlockLength * iZeroPadFactor;

    m_ePrePostWindowOpt = eWindowing;

    rErr = allocMemory ();
    if (rErr)
        return rErr;

    rErr = computeWindow (eWindow);

    m_bIsInitialized    = true;

    return rErr;
}
Пример #6
0
void openTrace(void)    
    {
    if(traceFlag) return;
    traceFlag = TRACE_TRUE;
    currentFunc = nilSymbol;
    debugStackIdx = 0;
    debugStack = (UINT *)allocMemory(MAX_CPU_STACK * 2 * sizeof(UINT));
    }
Пример #7
0
u32 allocMemoryInPage(u32 size)
{
    if (size>0) {
        size = (size+0xfff)&0xfffff000;
        return allocMemory(size);
    }
    return 0;
}
Пример #8
0
void MatrixMxN<Scalar>::resize(unsigned int new_rows, unsigned int new_cols)
{
#ifdef PHYSIKA_USE_EIGEN_MATRIX
    (*ptr_eigen_matrix_MxN_).resize(new_rows,new_cols);
#elif defined(PHYSIKA_USE_BUILT_IN_MATRIX)
    delete[] data_;
    allocMemory(new_rows, new_cols);
#endif
}
Пример #9
0
StartButton *createStartButton(int x, int y, int w, int h, u32 sector)
{
	StartButton *startButton = (StartButton *)allocMemory(sizeof(StartButton));
	startButton = (StartButton*)initWithViewFunction((View*)startButton, x, y, w, h);
	(*startButton).initWithImage = initWithImage;
	Image *image = loadImageFromStorage(sector);
	(*startButton).initWithImage(startButton, image);
	
	return startButton;
}
Пример #10
0
void CThreadError::operator=(thread_error_t & st)
{
	 unsigned int tid = CLightThread::GetCurrentThreadId();
	 internal_thread_error_t *temp = search(tid);
	 if(!temp)
		 {
			 temp = allocMemory(tid);
			 }
	 memcpy(&temp->threaderror, &st, sizeof(thread_error_t));
}
Пример #11
0
VectorND<Scalar>::VectorND(const VectorND<Scalar> &vec2)
#ifdef PHYSIKA_USE_EIGEN_VECTOR
    :eigen_vector_Nx_(vec2.eigen_vector_Nx_)
#endif 
{
#ifdef PHYSIKA_USE_BUILT_IN_VECTOR
    allocMemory(vec2.dims());
    *this = vec2;
#endif  
}
Пример #12
0
extern struct Deque *
deque_createDeque()
{
    struct Deque *deque;

    deque = (struct Deque *) allocMemory(1, sizeof (struct Deque));
    if (!deque) return (struct Deque *) 0;
    deque->first = deque->last = (struct DequeEntry *) 0;

    return deque;
}
Пример #13
0
GraphPanel *createGraphPanel(int x, int y, int w, int h)
{
	GraphPanel *graphPanel = (GraphPanel *)allocMemory(sizeof(GraphPanel));
	graphPanel = (GraphPanel*)initWithViewFunction((View*)graphPanel, x, y, w, h);
	(*graphPanel).canvas = createView(x, y, w, h);	
	(*graphPanel).initPanel = initGraphPanel;
	(*graphPanel).initPanel(graphPanel);
	(*graphPanel).view.onMouseDown = onMouseDown;
	
	return graphPanel;
}
Пример #14
0
void CThreadError::operator=(const char * msg)
{
	 unsigned int tid = CLightThread::GetCurrentThreadId();
	 internal_thread_error_t *temp = search(tid);
	 if(!temp)
		 {
			 temp = allocMemory(tid);
			 }
	 temp->threaderror.errorno = GX_UNDEFINED;
	 gxstrcpy(temp->threaderror.errormsg, 510, msg);
}
Пример #15
0
void CThreadError::operator=(int errorno)
{
	 unsigned int tid = CLightThread::GetCurrentThreadId();
	 internal_thread_error_t *temp = search(tid);
	 if(!temp)
		 {
			 temp = allocMemory(tid);
			 }
	 temp->threaderror.errorno = errorno;
	 temp->threaderror.errormsg[0] = '\0';
}
MultiLayerNet *MultiLayerFactory::createFromFile(const QString &filename) {
    currentMode = 0;
    MultiLayerNet *bpNewNet = 0;
    parseFile(filename);
    bpNewNet = allocMemory(bpNewNet);

    if (recArea != "")
        bpNewNet->setRecArea(recArea);

    return bpNewNet;
}
Пример #17
0
VectorND<Scalar>::VectorND(unsigned int dim, Scalar value)
#ifdef PHYSIKA_USE_EIGEN_VECTOR
    :eigen_vector_Nx_(dim)
#endif 
{
#ifdef PHYSIKA_USE_BUILT_IN_VECTOR
    allocMemory(dim);
#endif

    for(unsigned int i = 0; i < dim; ++i)
        (*this)[i] = value;
}
Пример #18
0
int main()
{
    long long *numPtr;

    // 단일 포인터 long long *numPtr의 메모리 주소는 long long **와 같음, 할당할 크기도 넣음
    allocMemory(&numPtr, sizeof(long long));

    *numPtr = 10;
    printf("%lld\n", *numPtr);

    free(numPtr);    // 동적 메모리 해제

    return 0;
}
Пример #19
0
void VectorND<Scalar>::resize(unsigned int new_dim, Scalar init_val)
{
#ifdef PHYSIKA_USE_EIGEN_VECTOR
    eigen_vector_Nx_.resize(new_dim);
#elif defined(PHYSIKA_USE_BUILT_IN_VECTOR)
    if(data_)
        delete[] data_;
    allocMemory(new_dim);
#endif

    //initialize 
    for (unsigned int i = 0; i < new_dim; ++i)
        (*this)[i] = init_val;
}
Пример #20
0
Image* loadImageFromStorage(u32 sector)
{
    u8 *head = (u8 *)allocMemory(IMAGE_HEADER_SIZE);
    readHardDisk(sector, head, IMAGE_HEADER_SIZE);
    u16 *width = (u16 *)(head+4);
    u16 *height = (u16 *)(head+6);
    freeMemory((u32)head, IMAGE_HEADER_SIZE);

    u32 size = (*width)*(*height)*SCREEN_DENSITY;
   	u8 *buffer = (u8 *)allocMemory(size);

	readHardDisk(sector, buffer, size);

    Image *image = (Image*)allocMemoryInPage(sizeof(Image));
    (*image).width = 1024;
    (*image).height = 768;
    (*image).x = 0;
    (*image).y = 0;
    (*image).data = buffer+8;
    (*image).head = head;
    (*image).buffer = buffer;
    return image;
}
Пример #21
0
int main()
{
    long long *numPtr = NULL;

    // numPtr과 할당할 크기를 넣어줌 
    allocMemory(numPtr, sizeof(long long));

    *numPtr = 10;    // 메모리가 할당되지 않았으므로 실행 에러
    printf("%lld\n", *numPtr);

    free(numPtr);

    return 0;
}
Пример #22
0
extern void *
trimMemory(void *mem)
{
    int len;
    void *res;
    
    len = strlen((char *) mem);
    res = allocMemory(len + 1, sizeof (u1));
    if (!res)
        return (void *) 0;
    memcpy(res, mem, len);
    freeMemory(mem);
    
    return res;
}
Пример #23
0
void startMathematicsApplication()
{
	if (mathematicsProcess==null) {
		mathematicsProcess = requestProcess();
		(*mathematicsProcess).tss.esp = allocMemory(64 * 1024) + 64 * 1024;
		(*mathematicsProcess).tss.eip = (int) &mathematicsApplicationMain;
		(*mathematicsProcess).tss.es = 2 * 8;
		(*mathematicsProcess).tss.cs = 1 * 8;
		(*mathematicsProcess).tss.ss = 2 * 8;
		(*mathematicsProcess).tss.ds = 2 * 8;
		(*mathematicsProcess).tss.fs = 2 * 8;
		(*mathematicsProcess).tss.gs = 2 * 8;
		(*mathematicsProcess).tss.cr3 = 0x60000;

		startRunProcess(mathematicsProcess, 4);
	}
}
Пример #24
0
void startDataGraphApplication()
{
	if (dataGraphProcess==null) {
		dataGraphProcess = requestProcess();
		(*dataGraphProcess).tss.esp = allocMemory(64 * 1024) + 64 * 1024;
		(*dataGraphProcess).tss.eip = (int) &dataGraphApplicationMain;
		(*dataGraphProcess).tss.es = 2 * 8;
		(*dataGraphProcess).tss.cs = 1 * 8;
		(*dataGraphProcess).tss.ss = 2 * 8;
		(*dataGraphProcess).tss.ds = 2 * 8;
		(*dataGraphProcess).tss.fs = 2 * 8;
		(*dataGraphProcess).tss.gs = 2 * 8;
		(*dataGraphProcess).tss.cr3 = 0x60000;

		startRunProcess(dataGraphProcess, 4);
	}
}
Пример #25
0
CELL * p_dup(CELL * params)
{
CELL * list;
CELL * expr;
char * str;
ssize_t n, len;

expr = evaluateExpression(params);
if((params = params->next) != nilCell)
	getInteger(params, (UINT *)&n);
else n = 2;

if(n < 0) n = 0;

if(expr->type == CELL_STRING && !getFlag(params->next) )
	{
	len = expr->aux - 1;
	list = getCell(CELL_STRING);
	str = allocMemory(len * n + 1);
	list->contents = (UINT)str;
	list->aux = (len * n + 1);
	*(str + len * n) = 0;
	while(n--) 
		{
		memcpy(str, (char *)expr->contents, len);
		str += len;
		}
	return(list);
	}

list = getCell(CELL_EXPRESSION);
if(n-- > 0) 
	{
	list->contents = (UINT)copyCell(expr);

	params = (CELL *)list->contents;
	while(n--)
		{
		params->next = copyCell(expr);
		params = params->next;
		}
	}

return(list);
}
void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
{
    if( _batchNode != batchNode )
    {
        ParticleBatchNode* oldBatch = _batchNode;

        ParticleSystem::setBatchNode(batchNode);

        // NEW: is self render ?
        if( ! batchNode )
        {
            allocMemory();
            initIndices();
            setTexture(oldBatch->getTexture());
            if (Configuration::getInstance()->supportsShareableVAO())
            {
                setupVBOandVAO();
            }
            else
            {
                setupVBO();
            }
        }
        // OLD: was it self render ? cleanup
        else if( !oldBatch )
        {
            // copy current state to batch
            V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
            V3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] );
            memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) );

            CC_SAFE_FREE(_quads);
            CC_SAFE_FREE(_indices);

            glDeleteBuffers(2, &_buffersVBO[0]);
            memset(_buffersVBO, 0, sizeof(_buffersVBO));
            if (Configuration::getInstance()->supportsShareableVAO())
            {
                glDeleteVertexArrays(1, &_VAOname);
                GL::bindVAO(0);
                _VAOname = 0;
            }
        }
    }
}
Пример #27
0
void startCalculatorApplication()
{
	if (calculatorProcess==null) {
		calculatorProcess = requestProcess();
		prepareProcessLdt(calculatorProcess);
		(*calculatorProcess).tss.esp = allocMemory(64 * 1024) + 64 * 1024;
		(*calculatorProcess).tss.eip = (int) &calculatorApplicationMain;		
		(*calculatorProcess).tss.cs = 0 * 8 + 4;		
		(*calculatorProcess).tss.ds = 1 * 8 + 4;
		(*calculatorProcess).tss.es = 1 * 8 + 4;
		(*calculatorProcess).tss.fs = 1 * 8 + 4;
		(*calculatorProcess).tss.gs = 1 * 8 + 4;
		(*calculatorProcess).tss.ss = 2 * 8 + 4;
		(*calculatorProcess).tss.cr3 = 0x60000;
				
		startRunProcess(calculatorProcess, 4);
	}
}
Пример #28
0
void CCParticleSystemQuad::setBatchNode(CCParticleBatchNode * batchNode)
{
    if( m_pBatchNode != batchNode ) 
    {
        CCParticleBatchNode* oldBatch = m_pBatchNode;

        CCParticleSystem::setBatchNode(batchNode);

        // NEW: is self render ?
        if( ! batchNode ) 
        {
            allocMemory();
            initIndices();
            setTexture(oldBatch->getTexture());
#if CC_TEXTURE_ATLAS_USE_VAO
            setupVBOandVAO();
#else
            setupVBO();
#endif
        }
        // OLD: was it self render ? cleanup
        else if( !oldBatch )
        {
            // copy current state to batch
            ccV3F_C4B_T2F_Quad *batchQuads = m_pBatchNode->getTextureAtlas()->getQuads();
            ccV3F_C4B_T2F_Quad *quad = &(batchQuads[m_uAtlasIndex] );
            memcpy( quad, m_pQuads, m_uTotalParticles * sizeof(m_pQuads[0]) );

            CC_SAFE_FREE(m_pQuads);
            CC_SAFE_FREE(m_pIndices);

            glDeleteBuffers(2, &m_pBuffersVBO[0]);
            memset(m_pBuffersVBO, 0, sizeof(m_pBuffersVBO));
#if CC_TEXTURE_ATLAS_USE_VAO
            glDeleteVertexArrays(1, &m_uVAOname);
            ccGLBindVAO(0);
            m_uVAOname = 0;
#endif
        }
    }
}
Пример #29
0
SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {
    SkStream* stream = this->getLocalStream();
    if (stream) {
        // should have been provided by CreateFromStream()
        *ttcIndex = 0;

        SkAutoTUnref<SkStream> dupStream(stream->duplicate());
        if (dupStream) {
            return dupStream.detach();
        }

        // TODO: update interface use, remove the following code in this block.
        size_t length = stream->getLength();

        const void* memory = stream->getMemoryBase();
        if (NULL != memory) {
            return new SkMemoryStream(memory, length, true);
        }

        SkAutoTMalloc<uint8_t> allocMemory(length);
        stream->rewind();
        if (length == stream->read(allocMemory.get(), length)) {
            SkAutoTUnref<SkMemoryStream> copyStream(new SkMemoryStream());
            copyStream->setMemoryOwned(allocMemory.detach(), length);
            return copyStream.detach();
        }

        stream->rewind();
        stream->ref();
    } else {
        SkAutoTUnref<SkFontConfigInterface> fci(RefFCI());
        if (NULL == fci.get()) {
            return NULL;
        }
        stream = fci->openStream(this->getIdentity());
        *ttcIndex = this->getIdentity().fTTCIndex;
    }
    return stream;
}
Пример #30
0
extern int
deque_addLast(struct Deque *deque, int size, void *value)
{
    struct DequeEntry *entry;

    if (!deque)
    {
        logError("Parameter 'deque' is NULL in method %s!\r\n", __func__);
        return -1;
    }
    entry = (struct DequeEntry *) allocMemory(1, sizeof (struct DequeEntry));
    if (!entry) return -1;
    entry->size = size;
    entry->value = value;
    entry->prev = deque->last;
    entry->next = (struct DequeEntry *) 0;
    if (deque->last)
        deque->last->next = entry;
    else // deque is empty
        deque->first = entry;
    deque->last = entry;

    return 0;
}