当前位置: 首页>>代码示例>>C++>>正文


C++ crAlloc函数代码示例

本文整理汇总了C++中crAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ crAlloc函数的具体用法?C++ crAlloc怎么用?C++ crAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了crAlloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: crServerDispatchGetUniformfv

void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params)
{
    int size = __GetUniformSize(program, location) * sizeof(GLfloat);
    GLfloat *pLocal;

    pLocal = (GLfloat*) crAlloc(size);
    if (!pLocal)
    {
        GLsizei zero=0;
        crServerReturnValue(&zero, sizeof(zero));
    }

    cr_server.head_spu->dispatch_table.GetUniformfv(crStateGetProgramHWID(program), location, pLocal);

    crServerReturnValue(pLocal, size);
    crFree(pLocal);
}
开发者ID:quiquetux,项目名称:jokte-ba-as,代码行数:17,代码来源:server_getshaders.c

示例2: DECLEXPORT

DECLEXPORT(void) STATE_APIENTRY crStateBindAttribLocation(GLuint program, GLuint index, const char * name)
{
    CRGLSLProgram *pProgram = crStateGetProgramObj(program);
    GLuint i;
    CRGLSLAttrib *pAttribs;

    if (!pProgram)
    {
        crWarning("Unknown program %d", program);
        return;
    }

    if (index>=CR_MAX_VERTEX_ATTRIBS)
    {
        crWarning("crStateBindAttribLocation: Index too big %d", index);
        return;
    }

    for (i=0; i<pProgram->currentState.cAttribs; ++i)
    {
        if (!crStrcmp(pProgram->currentState.pAttribs[i].name, name))
        {
            pProgram->currentState.pAttribs[i].index = index;
            return;
        }
    }

    pAttribs = (CRGLSLAttrib*) crAlloc((pProgram->currentState.cAttribs+1)*sizeof(CRGLSLAttrib));
    if (!pAttribs)
    {
        crWarning("crStateBindAttribLocation: Out of memory!");
        return;
    }

    if (pProgram->currentState.cAttribs)
    {
        crMemcpy(&pAttribs[0], &pProgram->currentState.pAttribs[0], pProgram->currentState.cAttribs*sizeof(CRGLSLAttrib));
    }
    pAttribs[pProgram->currentState.cAttribs].index = index;
    pAttribs[pProgram->currentState.cAttribs].name = crStrdup(name);
    
    pProgram->currentState.cAttribs++;
    if (pProgram->currentState.pAttribs) crFree(pProgram->currentState.pAttribs);
    pProgram->currentState.pAttribs = pAttribs;
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:45,代码来源:state_glsl.c

示例3: crServerDispatchSemaphorePCR

/* Semaphore wait */
void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphorePCR( GLuint name )
{
	CRServerSemaphore *sema;

	if (cr_server.ignore_papi)
	{
		cr_server.head_spu->dispatch_table.SemaphorePCR( name );
		return;
	}

	sema = (CRServerSemaphore *) crHashtableSearch( cr_server.semaphores, name );
	if (!sema)
	{
		crError( "No such semaphore: %d", name );
	}
	if (sema->count)
	{
		/* go */
		if (cr_server.debug_barriers)
			crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) decrement to %d",
							cr_server.curClient, name, sema->count, sema->count - 1);
		sema->count--;
	}
	else
	{
		/* block */
		wqnode *node;
		if (cr_server.debug_barriers)
			crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) - block.",
							cr_server.curClient, name, sema->count);
		cr_server.run_queue->blocked = 1;
		node = (wqnode *) crAlloc( sizeof( *node ) );
		node->q = cr_server.run_queue;
		node->next = NULL;
		if (sema->tail)
		{
			sema->tail->next = node;
		}
		else
		{
			sema->waiting = node;
		}
		sema->tail = node;
	}
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:46,代码来源:server_papi.c

示例4: AddVisualInfo

static void
AddVisualInfo(Display *dpy, int screen, VisualID visualid, int visBits)
{
	struct VisualInfo *v;
	for (v = VisualInfoList; v; v = v->next) {
		if (v->dpy == dpy && v->screen == screen && v->visualid == visualid) {
			v->visBits |= visBits;
			return;
		}
	}
	v = (struct VisualInfo *) crAlloc(sizeof(struct VisualInfo));
	v->dpy = dpy;
	v->screen = screen;
	v->visualid = visualid;
	v->visBits = visBits;
	v->next = VisualInfoList;
	VisualInfoList = v;
}
开发者ID:alown,项目名称:chromium,代码行数:18,代码来源:glx.c

示例5: crServerDispatchGetInfoLogARB

void SERVER_DISPATCH_APIENTRY crServerDispatchGetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog)
{
    GLsizei *pLocal;
    GLuint hwid;

    pLocal = (GLsizei*) crAlloc(maxLength+sizeof(GLsizei));
    if (!pLocal)
    {
        GLsizei zero=0;
        crServerReturnValue(&zero, sizeof(zero));
    }
    /*@todo: recheck*/
    hwid = crStateGetProgramHWID(obj);
    if (!hwid) hwid = crStateGetShaderHWID(obj);
    cr_server.head_spu->dispatch_table.GetInfoLogARB(hwid, maxLength, pLocal, (char*)&pLocal[1]);
    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
    crFree(pLocal);
}
开发者ID:quiquetux,项目名称:jokte-ba-as,代码行数:18,代码来源:server_getshaders.c

示例6: AllocBuffers

/**
 * Allocate the color and depth buffers needed for the glDraw/ReadPixels
 * commands for the given window.
 */
static void
AllocBuffers(WindowInfo * window)
{
	CRASSERT(window);
	CRASSERT(window->width >= 0);
	CRASSERT(window->height >= 0);

	if (window->msgBuffer)
		crFree(window->msgBuffer);

	window->msgBuffer = (GLubyte *) crAlloc(sizeof(BinarySwapMsg) +
																					window->width * window->height
																					* ((window->bytesPerDepth +
																							window->bytesPerColor) *
																						 sizeof(GLubyte)));
	/* Setup message type to keep network layer happy */
	((BinarySwapMsg *) window->msgBuffer)->header.type = CR_MESSAGE_OOB;
}
开发者ID:alown,项目名称:chromium,代码行数:22,代码来源:binaryswapspu.c

示例7: crServerDispatchReadPixels

void SERVER_DISPATCH_APIENTRY
crServerDispatchReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
														GLenum format, GLenum type, GLvoid *pixels)
{
	/* Note: this local var overrides the global var in cr_unpack.h */
	const unsigned char *cr_unpackData = crUnpackGetDataPointer();
	CRMessageReadPixels *rp;
	const GLint stride = READ_DATA( 24, GLint );
	const GLint alignment = READ_DATA( 28, GLint );
	const GLint skipRows = READ_DATA( 32, GLint );
	const GLint skipPixels = READ_DATA( 36, GLint );
	const GLint bytes_per_row = READ_DATA( 40, GLint );
	const GLint rowLength = READ_DATA( 44, GLint );
	const int msg_len = sizeof(*rp) + bytes_per_row * height;

	CRASSERT(bytes_per_row > 0);

	rp = (CRMessageReadPixels *) crAlloc( msg_len );

	/* Note: the ReadPixels data gets densely packed into the buffer
	 * (no skip pixels, skip rows, etc.  It's up to the receiver (pack spu,
	 * tilesort spu, etc) to apply the real PixelStore packing parameters.
	 */
	cr_server.head_spu->dispatch_table.ReadPixels( x, y, width, height,
																								 format, type, rp + 1);

	rp->header.type = CR_MESSAGE_READ_PIXELS;
	rp->width = width;
	rp->height = height;
	rp->bytes_per_row = bytes_per_row;
	rp->stride = stride;
	rp->format = format;
	rp->type = type;
	rp->alignment = alignment;
	rp->skipRows = skipRows;
	rp->skipPixels = skipPixels;
	rp->rowLength = rowLength;

	/* <pixels> points to the 8-byte network pointer */
	crMemcpy( &rp->pixels, pixels, sizeof(rp->pixels) );
	
	crNetSend( cr_server.curClient->conn, NULL, rp, msg_len );
	crFree( rp );
}
开发者ID:alown,项目名称:chromium,代码行数:44,代码来源:server_readpixels.c

示例8: packspu_WindowCreate

GLint PACKSPU_APIENTRY packspu_WindowCreate( const char *dpyName, GLint visBits )
{
	static int num_calls = 0;
	int writeback = pack_spu.thread[0].netServer.conn->actual_network;
	GLint return_val = (GLint) 0;
	WindowInfo *WInfo;

	/* WindowCreate is special - just like CreateContext.
	 * GET_THREAD(thread) doesn't work as the thread won't have called
	 * MakeCurrent yet, so we've got to use the first thread's packer
	 * buffer.
	 */

	crPackSetContext( pack_spu.thread[0].packer );

	if (pack_spu.swap)
	{
		crPackWindowCreateSWAP( dpyName, visBits, &return_val, &writeback );
	}
	else
	{
		crPackWindowCreate( dpyName, visBits, &return_val, &writeback );
	}
	packspuFlush( &pack_spu.thread[0] );
	if (!(pack_spu.thread[0].netServer.conn->actual_network))
	{
		return num_calls++;
	}
	else
	{
		while (writeback)
			crNetRecv();
		if (pack_spu.swap)
		{
			return_val = (GLint) SWAP32(return_val);
		}
		WInfo = (WindowInfo *) crAlloc(sizeof(WindowInfo));
		WInfo->XWindow = 0;
		WInfo->visual = visBits;
		crHashtableAdd(pack_spu.XWindows,return_val,WInfo);
		return return_val;
	}
}
开发者ID:L3oV1nc3,项目名称:VMGL,代码行数:43,代码来源:packspu_misc.c

示例9: createSubMenu

static void
createSubMenu( apiMenu* newMenu )
{
    int i;

    /* begin copy subMenus - should re-implement this as a linked list*/
    apiMenu** tmp = crAlloc( sizeof(apiMenu*) * (crut_server.endStack->subMenus + 1) );

    for ( i=0; i < crut_server.endStack->subMenus; i++ )
	tmp[i]  = crut_server.endStack->tree[i];
    /* end copy subMenus */
    
    tmp[crut_server.endStack->subMenus] = newMenu;

    crut_server.endStack->tree = tmp;
    
    crut_server.endStack->subMenus++;

}
开发者ID:hanzhaogang,项目名称:chromium-1,代码行数:19,代码来源:main.c

示例10: SendOpcodes

/*
 * Send a Chromium opcode buffer across the given net connection.
 * size - size of opcode buffer in bytes.
 * exitFlag - if true, send 'exit' code to server.
 */
static void
SendOpcodes(CRConnection *conn, int size, int exitFlag)
{
	char *buffer, *firstCode;
	CRMessageOpcodes *msg;

	if (size <= MTU) {
		buffer = crNetAlloc(conn);

		msg = (CRMessageOpcodes *) buffer;
		msg->header.type = CR_MESSAGE_OPCODES;
		msg->numOpcodes = size;
		firstCode = buffer + sizeof(CRMessageOpcodes);
		if (exitFlag)
			 *firstCode = 42;
		else
			 *firstCode = 99;
		crNetSend(conn, NULL, buffer, MTU);

		crNetFree(conn, buffer);
	}
	else {
		/* send "huge" buffer */
		const int totalSize = size + 8 + sizeof(CRMessageOpcodes);
		unsigned int *uiptr;
		buffer = crAlloc(totalSize);
		msg = (CRMessageOpcodes *) buffer;
		msg->header.type = CR_MESSAGE_OPCODES;
		msg->numOpcodes = 1;
		uiptr = (unsigned int *) (buffer + sizeof(CRMessageOpcodes) + 4);
		uiptr[0] = size;

		firstCode = buffer + sizeof(CRMessageOpcodes);
		if (exitFlag)
			 *firstCode = 42;
		else
			 *firstCode = 99;

		crNetSend(conn, NULL, buffer, size);
		crFree(buffer);
	}
}
开发者ID:boompig,项目名称:chromium,代码行数:47,代码来源:npclient.c

示例11: crServerDispatchGetUniformsLocations

void SERVER_DISPATCH_APIENTRY 
crServerDispatchGetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
{
    GLsizei *pLocal;

    (void) cbData;
    (void) pData;

    pLocal = (GLsizei*) crAlloc(maxcbData+sizeof(GLsizei));
    if (!pLocal)
    {
        GLsizei zero=0;
        crServerReturnValue(&zero, sizeof(zero));
    }
    
    crStateGLSLProgramCacheUniforms(program, maxcbData, pLocal, (char*)&pLocal[1]);

    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
    crFree(pLocal);
}
开发者ID:greg100795,项目名称:virtualbox,代码行数:20,代码来源:server_getshaders.c

示例12: crServerDispatchPrioritizeTextures

void SERVER_DISPATCH_APIENTRY crServerDispatchPrioritizeTextures( GLsizei n, const GLuint * textures, const GLclampf * priorities )
{
    GLuint *newTextures = (GLuint *) crAlloc(n * sizeof(GLuint));
    GLint i;

    if (!newTextures)
    {
        crError("crServerDispatchDeleteTextures: out of memory");
        return;
    }

    for (i = 0; i < n; i++)
    {
        newTextures[i] = crStateGetTextureHWID(textures[i]);
    }

    crStatePrioritizeTextures(n, textures, priorities);
    cr_server.head_spu->dispatch_table.PrioritizeTextures(n, newTextures, priorities);
    crFree(newTextures);
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:20,代码来源:server_lists.c

示例13: packspu_GetAttachedObjectsARB

void PACKSPU_APIENTRY packspu_GetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj)
{
    GET_THREAD(thread);
    int writeback = 1;
    GLsizei *pLocal;

    if (!obj) return;

    pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLhandleARB)+sizeof(GLsizei));
    if (!pLocal) return;

    crPackGetAttachedObjectsARB(containerObj, maxCount, pLocal, NULL, &writeback);

    packspuFlush((void *) thread);
    CRPACKSPU_WRITEBACK_WAIT(thread, writeback);

    if (count) *count=*pLocal;
    crMemcpy(obj, &pLocal[1], *pLocal*sizeof(GLhandleARB));
    crFree(pLocal);
}
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:20,代码来源:packspu_getshaders.c

示例14: buildValueArray

static void
buildValueArray(void)
{
    int i;
    itemValue* item = crut_server.values;
    itemValue* temp;

    crut_server.valueTable = crAlloc( crut_server.numValues * sizeof( itemValue ) );

    for ( i=0; i < crut_server.numValues; i++ )
    {
	crut_server.valueTable[i].index = item->index;
	crut_server.valueTable[i].value = item->value;
	crut_server.valueTable[i].menuID = item->menuID;

	temp = item;
	item = item->next;
	crFree(temp);
    } 
}
开发者ID:hanzhaogang,项目名称:chromium-1,代码行数:20,代码来源:main.c

示例15: packspu_GetShaderInfoLog

void PACKSPU_APIENTRY packspu_GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, char * infoLog)
{
    GET_THREAD(thread);
    int writeback = 1;
    GLsizei *pLocal;

    if (!infoLog) return;

    pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
    if (!pLocal) return;

    crPackGetShaderInfoLog(shader, bufSize, pLocal, NULL, &writeback);

    packspuFlush((void *) thread);
    CRPACKSPU_WRITEBACK_WAIT(thread, writeback);

    if (length) *length=*pLocal;
    crMemcpy(infoLog, &pLocal[1], (bufSize >= pLocal[0]) ? pLocal[0] : bufSize);
    crFree(pLocal);
}
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:20,代码来源:packspu_getshaders.c


注:本文中的crAlloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。