本文整理汇总了C++中MALLOC_STRUCT函数的典型用法代码示例。如果您正苦于以下问题:C++ MALLOC_STRUCT函数的具体用法?C++ MALLOC_STRUCT怎么用?C++ MALLOC_STRUCT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MALLOC_STRUCT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _mesa_PushClientAttrib
void
_mesa_PushClientAttrib(GLbitfield mask)
{
struct gl_attrib_node *newnode;
struct gl_attrib_node *head;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) {
_mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );
return;
}
/* Build linked list of attribute nodes which save all attribute */
/* groups specified by the mask. */
head = NULL;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
struct gl_pixelstore_attrib *attr;
/* packing attribs */
attr = MALLOC_STRUCT( gl_pixelstore_attrib );
MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
/* unpacking attribs */
attr = MALLOC_STRUCT( gl_pixelstore_attrib );
MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
struct gl_array_attrib *attr;
attr = MALLOC_STRUCT( gl_array_attrib );
MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
ctx->ClientAttribStackDepth++;
}
示例2: MALLOC_STRUCT
struct dynfn *tnl_makeX86Attr4ubv( TNLcontext *tnl, int key )
{
struct dynfn *dfn = MALLOC_STRUCT( dynfn );
insert_at_head( &tnl->dfn_cache.Color4ubv, dfn );
dfn->key = key;
if (TNL_DEBUG & DEBUG_CODEGEN)
_mesa_debug(NULL, "%s 0x%08x\n", __FUNCTION__, key );
if (key & TNL_CP_VC_FRMT_PKCOLOR) {
static char temp[] = {
0x8b, 0x44, 0x24, 0x04, /* mov 0x4(%esp,1),%eax */
0xba, 0x78, 0x56, 0x34, 0x12, /* mov $DEST,%edx */
0x8b, 0x00, /* mov (%eax),%eax */
0x89, 0x02, /* mov %eax,(%edx) */
0xc3, /* ret */
};
dfn->code = ALIGN_MALLOC( sizeof(temp), 16 );
memcpy (dfn->code, temp, sizeof(temp));
FIXUP(dfn->code, 5, 0x12345678, (int)tnl->ubytecolorptr);
return dfn;
}
else {
static char temp[] = {
0x53, /* push %ebx */
0xba, 0x00, 0x00, 0x00, 0x00, /* mov $0x0,%edx */
0x31, 0xc0, /* xor %eax,%eax */
0x31, 0xc9, /* xor %ecx,%ecx */
0x8b, 0x5c, 0x24, 0x08, /* mov 0x8(%esp,1), %ebx */
0x8b, 0x1b, /* mov (%ebx), %ebx */
0x88, 0xd8, /* mov %bl, %al */
0x88, 0xf9, /* mov %bh, %cl */
0x8b, 0x04, 0x82, /* mov (%edx,%eax,4),%eax */
0x8b, 0x0c, 0x8a, /* mov (%edx,%ecx,4),%ecx */
0xa3, 0xaf, 0xbe, 0xad, 0xde, /* mov %eax,0xdeadbeaf */
0x89, 0x0d, 0xaf, 0xbe, 0xad, 0xde, /* mov %ecx,0xdeadbeaf */
0x31, 0xc0, /* xor %eax,%eax */
0x31, 0xc9, /* xor %ecx,%ecx */
0xc1, 0xeb, 0x10, /* shr $0x10, %ebx */
0x88, 0xd8, /* mov %bl, %al */
0x88, 0xf9, /* mov %bh, %cl */
0x8b, 0x04, 0x82, /* mov (%edx,%eax,4),%eax */
0x8b, 0x0c, 0x8a, /* mov (%edx,%ecx,4),%ecx */
0xa3, 0xaf, 0xbe, 0xad, 0xde, /* mov %eax,0xdeadbeaf */
0x89, 0x0d, 0xaf, 0xbe, 0xad, 0xde, /* mov %ecx,0xdeadbeaf */
0x5b, /* pop %ebx */
0xc3, /* ret */
};
dfn->code = ALIGN_MALLOC( sizeof(temp), 16 );
memcpy (dfn->code, temp, sizeof(temp));
FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab);
FIXUP(dfn->code, 27, 0xdeadbeaf, (int)tnl->floatcolorptr);
FIXUP(dfn->code, 33, 0xdeadbeaf, (int)tnl->floatcolorptr+4);
FIXUP(dfn->code, 55, 0xdeadbeaf, (int)tnl->floatcolorptr+8);
FIXUP(dfn->code, 61, 0xdeadbeaf, (int)tnl->floatcolorptr+12);
return dfn;
}
}
示例3: movq
static struct dynfn *makeSSENormal3fv( GLcontext *ctx, const int *key )
{
/* Requires P4 (sse2?)
*/
static unsigned char temp[] = {
0x8b, 0x44, 0x24, 0x04, /* mov 0x4(%esp,1),%eax */
0xba, 0x78, 0x56, 0x34, 0x12, /* mov $0x12345678,%edx */
0xf3, 0x0f, 0x7e, 0x00, /* movq (%eax),%xmm0 */
0x66, 0x0f, 0x6e, 0x48, 0x08, /* movd 0x8(%eax),%xmm1 */
0x66, 0x0f, 0xd6, 0x42, 0x0c, /* movq %xmm0,0xc(%edx) */
0x66, 0x0f, 0x7e, 0x4a, 0x14, /* movd %xmm1,0x14(%edx) */
0xc3, /* ret */
};
struct dynfn *dfn = MALLOC_STRUCT( dynfn );
r200ContextPtr rmesa = R200_CONTEXT(ctx);
insert_at_head( &rmesa->vb.dfn_cache.Normal3fv, dfn );
dfn->key[0] = key[0];
dfn->key[1] = key[1];
dfn->code = ALIGN_MALLOC( sizeof(temp), 16 );
memcpy (dfn->code, temp, sizeof(temp));
FIXUP(dfn->code, 5, 0x0, (int)vb.normalptr);
return dfn;
}
示例4: sp_alloc_tile
static struct softpipe_cached_tile *
sp_alloc_tile(struct softpipe_tile_cache *tc)
{
struct softpipe_cached_tile * tile = MALLOC_STRUCT(softpipe_cached_tile);
if (!tile)
{
/* in this case, steal an existing tile */
if (!tc->tile)
{
unsigned pos;
for (pos = 0; pos < NUM_ENTRIES; ++pos) {
if (!tc->entries[pos])
continue;
sp_flush_tile(tc, pos);
tc->tile = tc->entries[pos];
tc->entries[pos] = NULL;
break;
}
/* this should never happen */
if (!tc->tile)
abort();
}
tile = tc->tile;
tc->tile = NULL;
tc->last_tile_addr.bits.invalid = 1;
}
return tile;
}
示例5: nvc0_so_target_create
static struct pipe_stream_output_target *
nvc0_so_target_create(struct pipe_context *pipe,
struct pipe_resource *res,
unsigned offset, unsigned size)
{
struct nvc0_so_target *targ = MALLOC_STRUCT(nvc0_so_target);
if (!targ)
return NULL;
targ->pq = pipe->create_query(pipe, NVC0_QUERY_TFB_BUFFER_OFFSET);
if (!targ->pq) {
FREE(targ);
return NULL;
}
targ->clean = TRUE;
targ->pipe.buffer_size = size;
targ->pipe.buffer_offset = offset;
targ->pipe.context = pipe;
targ->pipe.buffer = NULL;
pipe_resource_reference(&targ->pipe.buffer, res);
pipe_reference_init(&targ->pipe.reference, 1);
return &targ->pipe;
}
示例6: _mesa_new_query_object
/**
* Allocate a new query object. This is a fallback routine called via
* ctx->Driver.NewQueryObject().
* \param ctx - rendering context
* \param id - the new object's ID
* \return pointer to new query_object object or NULL if out of memory.
*/
struct gl_query_object *
_mesa_new_query_object(struct gl_context *ctx, GLuint id)
{
struct gl_query_object *q = MALLOC_STRUCT(gl_query_object);
(void) ctx;
if (q) {
q->Id = id;
q->Result = 0;
q->Active = GL_FALSE;
/* This is to satisfy the language of the specification: "In the initial
* state of a query object, the result is available" (OpenGL 3.1 §
* 2.13).
*/
q->Ready = GL_TRUE;
/* OpenGL 3.1 § 2.13 says about GenQueries, "These names are marked as
* used, but no object is associated with them until the first time they
* are used by BeginQuery." Since our implementation actually does
* allocate an object at this point, use a flag to indicate that this
* object has not yet been bound so should not be considered a query.
*/
q->EverBound = GL_FALSE;
}
return q;
}
示例7: nvc0_so_target_create
static struct pipe_stream_output_target *
nvc0_so_target_create(struct pipe_context *pipe,
struct pipe_resource *res,
unsigned offset, unsigned size)
{
struct nv04_resource *buf = (struct nv04_resource *)res;
struct nvc0_so_target *targ = MALLOC_STRUCT(nvc0_so_target);
if (!targ)
return NULL;
targ->pq = pipe->create_query(pipe, NVC0_HW_QUERY_TFB_BUFFER_OFFSET, 0);
if (!targ->pq) {
FREE(targ);
return NULL;
}
targ->clean = true;
targ->pipe.buffer_size = size;
targ->pipe.buffer_offset = offset;
targ->pipe.context = pipe;
targ->pipe.buffer = NULL;
pipe_resource_reference(&targ->pipe.buffer, res);
pipe_reference_init(&targ->pipe.reference, 1);
assert(buf->base.target == PIPE_BUFFER);
util_range_add(&buf->valid_buffer_range, offset, offset + size);
return &targ->pipe;
}
示例8: _mesa_HashInsert
/**
* Insert into the hash table. If an entry with this key already exists
* we'll replace the existing entry.
* \param table - the hash table
* \param key - the key (not zero)
* \param data - pointer to user data
*/
void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
{
/* search for existing entry with this key */
GLuint pos;
struct HashEntry *entry;
assert(table);
assert(key);
_glthread_LOCK_MUTEX(table->Mutex);
if (key > table->MaxKey)
table->MaxKey = key;
pos = key & (TABLE_SIZE-1);
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
/* replace entry's data */
entry->Data = data;
_glthread_UNLOCK_MUTEX(table->Mutex);
return;
}
entry = entry->Next;
}
/* alloc and insert new table entry */
entry = MALLOC_STRUCT(HashEntry);
entry->Key = key;
entry->Data = data;
entry->Next = table->Table[pos];
table->Table[pos] = entry;
_glthread_UNLOCK_MUTEX(table->Mutex);
}
示例9: MALLOC_STRUCT
struct dynfn *radeon_makeX86Color4ubv( GLcontext *ctx, int key )
{
struct dynfn *dfn = MALLOC_STRUCT( dynfn );
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
if (RADEON_DEBUG & DEBUG_CODEGEN)
fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
if (key & RADEON_CP_VC_FRMT_PKCOLOR) {
DFN ( _x86_Color4ubv_ub, rmesa->vb.dfn_cache.Color4ubv);
FIXUP(dfn->code, 5, 0x12345678, (int)rmesa->vb.colorptr);
return dfn;
}
else {
DFN ( _x86_Color4ubv_4f, rmesa->vb.dfn_cache.Color4ubv);
FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab);
FIXUP(dfn->code, 27, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr);
FIXUP(dfn->code, 33, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+4);
FIXUP(dfn->code, 55, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+8);
FIXUP(dfn->code, 61, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+12);
return dfn;
}
}
示例10: nv50_so_target_create
static struct pipe_stream_output_target *
nv50_so_target_create(struct pipe_context *pipe,
struct pipe_resource *res,
unsigned offset, unsigned size)
{
struct nv04_resource *buf = (struct nv04_resource *)res;
struct nv50_so_target *targ = MALLOC_STRUCT(nv50_so_target);
if (!targ)
return NULL;
if (nouveau_context(pipe)->screen->class_3d >= NVA0_3D_CLASS) {
targ->pq = pipe->create_query(pipe,
NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET, 0);
if (!targ->pq) {
FREE(targ);
return NULL;
}
} else {
targ->pq = NULL;
}
targ->clean = TRUE;
targ->pipe.buffer_size = size;
targ->pipe.buffer_offset = offset;
targ->pipe.context = pipe;
targ->pipe.buffer = NULL;
pipe_resource_reference(&targ->pipe.buffer, res);
pipe_reference_init(&targ->pipe.reference, 1);
assert(buf->base.target == PIPE_BUFFER);
util_range_add(&buf->valid_buffer_range, offset, offset + size);
return &targ->pipe;
}
示例11: MALLOC_STRUCT
struct dynfn *r200_makeX86Color4ubv( GLcontext *ctx, const int *key )
{
struct dynfn *dfn = MALLOC_STRUCT( dynfn );
r200ContextPtr rmesa = R200_CONTEXT(ctx);
if (R200_DEBUG & DEBUG_CODEGEN)
fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
if (VTX_COLOR(key[0],0) == R200_VTX_PK_RGBA) {
DFN ( _x86_Color4ubv_ub, rmesa->vb.dfn_cache.Color4ubv);
FIXUP(dfn->code, 5, 0x12345678, (int)vb.colorptr);
return dfn;
}
else {
DFN ( _x86_Color4ubv_4f, rmesa->vb.dfn_cache.Color4ubv);
FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab);
FIXUP(dfn->code, 27, 0xdeadbeaf, (int)vb.floatcolorptr);
FIXUP(dfn->code, 33, 0xdeadbeaf, (int)vb.floatcolorptr+4);
FIXUP(dfn->code, 55, 0xdeadbeaf, (int)vb.floatcolorptr+8);
FIXUP(dfn->code, 61, 0xdeadbeaf, (int)vb.floatcolorptr+12);
return dfn;
}
}
示例12: R200_CONTEXT
struct dynfn *r200_makeX86Vertex3fv( GLcontext *ctx, const int *key )
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
struct dynfn *dfn = MALLOC_STRUCT( dynfn );
if (R200_DEBUG & DEBUG_CODEGEN)
fprintf(stderr, "%s 0x%08x 0x%08x %d\n", __FUNCTION__,
key[0], key[1], vb.vertex_size );
switch (vb.vertex_size) {
case 6: {
DFN ( _x86_Vertex3fv_6, rmesa->vb.dfn_cache.Vertex3fv );
FIXUP(dfn->code, 1, 0x00000000, (int)&vb.dmaptr);
FIXUP(dfn->code, 27, 0x0000001c, (int)&vb.vertex[3]);
FIXUP(dfn->code, 33, 0x00000020, (int)&vb.vertex[4]);
FIXUP(dfn->code, 45, 0x00000024, (int)&vb.vertex[5]);
FIXUP(dfn->code, 56, 0x00000000, (int)&vb.dmaptr);
FIXUP(dfn->code, 61, 0x00000004, (int)&vb.counter);
FIXUP(dfn->code, 67, 0x00000004, (int)&vb.counter);
FIXUP(dfn->code, 76, 0x00000008, (int)&vb.notify);
break;
}
case 8: {
DFN ( _x86_Vertex3fv_8, rmesa->vb.dfn_cache.Vertex3fv );
FIXUP(dfn->code, 1, 0x00000000, (int)&vb.dmaptr);
FIXUP(dfn->code, 27, 0x0000001c, (int)&vb.vertex[3]);
FIXUP(dfn->code, 33, 0x00000020, (int)&vb.vertex[4]);
FIXUP(dfn->code, 45, 0x0000001c, (int)&vb.vertex[5]);
FIXUP(dfn->code, 51, 0x00000020, (int)&vb.vertex[6]);
FIXUP(dfn->code, 63, 0x00000024, (int)&vb.vertex[7]);
FIXUP(dfn->code, 74, 0x00000000, (int)&vb.dmaptr);
FIXUP(dfn->code, 79, 0x00000004, (int)&vb.counter);
FIXUP(dfn->code, 85, 0x00000004, (int)&vb.counter);
FIXUP(dfn->code, 94, 0x00000008, (int)&vb.notify);
break;
}
default: {
DFN ( _x86_Vertex3fv, rmesa->vb.dfn_cache.Vertex3fv );
FIXUP(dfn->code, 8, 0x01010101, (int)&vb.dmaptr);
FIXUP(dfn->code, 32, 0x00000006, vb.vertex_size-3);
FIXUP(dfn->code, 37, 0x00000058, (int)&vb.vertex[3]);
FIXUP(dfn->code, 45, 0x01010101, (int)&vb.dmaptr);
FIXUP(dfn->code, 50, 0x02020202, (int)&vb.counter);
FIXUP(dfn->code, 58, 0x02020202, (int)&vb.counter);
FIXUP(dfn->code, 67, 0x0, (int)&vb.notify);
break;
}
}
return dfn;
}
示例13: MALLOC_STRUCT
static struct tnl_primitive_store *alloc_prim_store( GLcontext *ctx )
{
struct tnl_primitive_store *store = MALLOC_STRUCT(tnl_primitive_store);
(void) ctx;
store->used = 0;
store->refcount = 1;
return store;
}
示例14: lll_get_symbol
struct lll_object *
lll_get_symbol(const char *symbol_string) {
if (!lll_correct_symbol_string_p(symbol_string)) {
lll_error(2, symbol_string, __FILE__, __LINE__);
return NULL;
}
char *lowercase_version = lll_to_lowercase(symbol_string);
if (strcmp(lowercase_version, "nil") == 0) {
free(lowercase_version);
return NULL;
}
struct lll_symbol_entry *entry = &hash_table[hash_func(lowercase_version)];
while (true) {
/* haven't binded symbols. */
if (entry == NULL) {
entry = MALLOC_STRUCT(lll_symbol_entry);
entry->string = lowercase_version;
struct lll_object *obj = lll_csymbol(entry->string);
//obj->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);
entry->symbol = obj;
entry->another_entry = NULL;
return entry->symbol;
}
if (entry->string == NULL) {
entry->string = lowercase_version;
entry->symbol = lll_csymbol(entry->string);
entry->symbol->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);
return entry->symbol;
}
if (strcmp(entry->string, lowercase_version) == 0) {
/* So we have one copy in hash_table. Free second. */
free(lowercase_version);
/* string not binded yet */
if (entry->symbol == NULL) {
entry->symbol = lll_csymbol(entry->string);
entry->symbol->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);
return entry->symbol;
}
/* string binded */
else {
return entry->symbol;
}
}
entry = entry->another_entry;
}
}
示例15: new_attrib_node
/*
* Allocate a new attribute state node. These nodes have a
* "kind" value and a pointer to a struct of state data.
*/
static struct gl_attrib_node *
new_attrib_node( GLbitfield kind )
{
struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node);
if (an) {
an->kind = kind;
}
return an;
}