本文整理汇总了C++中POOL_ALLOC函数的典型用法代码示例。如果您正苦于以下问题:C++ POOL_ALLOC函数的具体用法?C++ POOL_ALLOC怎么用?C++ POOL_ALLOC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了POOL_ALLOC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildflagset_create
buildflagset_t* buildflagset_create()
{
buildflagset_t* p = POOL_ALLOC(buildflagset_t);
assert(p != NULL);
p->have_os_flags = false;
p->have_size_flags = false;
p->started_enum = false;
p->flags = POOL_ALLOC(flagtab_t);
flagtab_init(p->flags, 8);
p->text_buffer = NULL;
p->buffer_size = 0;
return p;
}
示例2: detect
static bool detect(pony_ctx_t* ctx, detector_t* d, view_t* view)
{
assert(view->perceived == NULL);
scan_grey(d, view, 0);
int count = scan_white(view);
assert(count >= 0);
if(count == 0)
return false;
d->detected++;
perceived_t* per = (perceived_t*)POOL_ALLOC(perceived_t);
per->token = d->next_token++;
per->ack = 0;
per->last_conf = HASHMAP_BEGIN;
ponyint_viewmap_init(&per->map, count);
ponyint_perceivedmap_put(&d->perceived, per);
int count2 = collect_white(per, view, 0);
(void)count2;
assert(count2 == count);
assert(ponyint_viewmap_size(&per->map) == (size_t)count);
send_conf(ctx, d, per);
return true;
}
示例3: package_group_new
package_group_t* package_group_new()
{
package_group_t* group = POOL_ALLOC(package_group_t);
group->signature = NULL;
package_set_init(&group->members, 1);
return group;
}
示例4: errors_alloc
errors_t* errors_alloc()
{
errors_t* errors = POOL_ALLOC(errors_t);
memset(errors, 0, sizeof(errors_t));
errors->output_stream = stderr;
return errors;
}
示例5: pony_deserialise_offset
void* pony_deserialise_offset(pony_ctx_t* ctx, pony_type_t* t,
uintptr_t offset)
{
// If the high bit of the offset is set, it is either an unserialised
// primitive, or an unserialised field in an opaque object.
if((offset & HIGH_BIT) != 0)
{
offset &= ~HIGH_BIT;
if(offset > __DescTableSize)
return NULL;
// Return the global instance, if there is one. It's ok to return null if
// there is no global instance, as this will then be an unserialised
// field in an opaque object.
t = (&__DescTable)[offset];
return t->instance;
}
// Lookup the offset, return the associated object if there is one.
serialise_t k;
k.key = offset;
serialise_t* s = ponyint_serialise_get(&ctx->serialise, &k);
if(s != NULL)
return (void*)s->value;
// If we haven't been passed a type descriptor, read one.
if(t == NULL)
{
// Make sure we have space to read a type id.
if((offset + sizeof(uintptr_t)) > ctx->serialise_size)
pony_throw();
// Turn the type id into a descriptor pointer.
uintptr_t id = *(uintptr_t*)((uintptr_t)ctx->serialise_buffer + offset);
t = (&__DescTable)[id];
}
// If it's a primitive, return the global instance.
if(t->instance != NULL)
return t->instance;
// Make sure we have space to read the object.
if((offset + t->size) > ctx->serialise_size)
pony_throw();
// Allocate the object, memcpy to it.
void* object = pony_alloc(ctx, t->size);
memcpy(object, (void*)((uintptr_t)ctx->serialise_buffer + offset), t->size);
// Store a mapping of offset to object.
s = POOL_ALLOC(serialise_t);
s->key = offset;
s->value = (uintptr_t)object;
ponyint_serialise_put(&ctx->serialise, s);
recurse(ctx, object, t->deserialise);
return object;
}
示例6: add_rmethod
static void add_rmethod(reachable_method_stack_t** s,
reachable_type_t* t, reachable_method_name_t* n, ast_t* typeargs)
{
const char* name = genname_fun(NULL, n->name, typeargs);
reachable_method_t* m = reach_method(n, name);
if(m == NULL)
{
m = POOL_ALLOC(reachable_method_t);
m->name = name;
m->typeargs = ast_dup(typeargs);
m->vtable_index = (uint32_t)-1;
ast_t* fun = lookup(NULL, NULL, t->type, n->name);
if(typeargs != NULL)
{
// Reify the method with its typeargs, if it has any.
AST_GET_CHILDREN(fun, cap, id, typeparams, params, result, can_error,
body);
ast_t* r_fun = reify(fun, typeparams, typeargs);
ast_free_unattached(fun);
fun = r_fun;
}
m->r_fun = ast_dup(fun);
ast_free_unattached(fun);
reachable_methods_put(&n->r_methods, m);
// Put on a stack of reachable methods to trace.
*s = reachable_method_stack_push(*s, m);
}
}
示例7: pony_asio_event_create
PONY_API asio_event_t* pony_asio_event_create(pony_actor_t* owner, int fd,
uint32_t flags, uint64_t nsec, bool noisy)
{
if((flags == ASIO_DISPOSABLE) || (flags == ASIO_DESTROYED))
return NULL;
pony_type_t* type = *(pony_type_t**)owner;
uint32_t msg_id = type->event_notify;
if(msg_id == (uint32_t)-1)
return NULL;
asio_event_t* ev = POOL_ALLOC(asio_event_t);
ev->magic = ev;
ev->owner = owner;
ev->msg_id = msg_id;
ev->fd = fd;
ev->flags = flags;
ev->noisy = noisy;
ev->nsec = nsec;
ev->writeable = false;
ev->readable = false;
// The event is effectively being sent to another thread, so mark it here.
pony_ctx_t* ctx = pony_ctx();
pony_gc_send(ctx);
pony_traceknown(ctx, owner, type, PONY_TRACE_OPAQUE);
pony_send_done(ctx);
pony_asio_event_subscribe(ev);
return ev;
}
示例8: insertString
/* 7.4 */
SWmlString * insertString(SDocData *data,
PString s)
{
/*
* Place a copy of 's' into the 'm_stringTable' of DocData,
* and treat it as 'inline'.
*
*---------------------------------------------------------------------------
*/
/* Data Structures */
SWmlString *_node;
/* Code */
POOL_ALLOC(DOCPOOL, _node);
_node->m_string = strXDup(s,DOCPOOL);
_node->m_site = STR_INLINE;
_node->m_offset = ~0;
if(STR_LEN(s)) {
SLL_INSERT(data->m_stringTable[ (*(STR_DATA(s)))&0x7f], _node);
}
else {
SLL_INSERT(data->m_stringTable[0], _node);
}
return _node;
}
示例9: builder_create
builder_t* builder_create(const char* description)
{
if(description == NULL)
return NULL;
source_t* source = source_open_string(description);
symtab_t* symtab = symtab_new();
ast_t* ast = build_ast(source, symtab);
if(ast == NULL)
{
// Error, tidy up
source_close(source);
symtab_free(symtab);
return NULL;
}
// Success, create builder
builder_t* builder = POOL_ALLOC(builder_t);
builder->sources = NULL;
builder->defs = symtab;
builder->dummy_root = ast_blank(TK_TEST);
ast_add(builder->dummy_root, ast);
add_source(builder, source);
return builder;
}
示例10: add_rmethod_to_subtype
static void add_rmethod_to_subtype(reach_t* r, reach_type_t* t,
reach_method_name_t* n, reach_method_t* m, pass_opt_t* opt)
{
// Add the method to the type if it isn't already there.
reach_method_name_t* n2 = add_method_name(t, n->name);
add_rmethod(r, t, n2, m->cap, m->typeargs, opt);
// Add this mangling to the type if it isn't already there.
reach_method_t* mangled = reach_mangled_get(&n2->r_mangled, m);
if(mangled != NULL)
return;
mangled = POOL_ALLOC(reach_method_t);
memset(mangled, 0, sizeof(reach_method_t));
mangled->name = m->name;
mangled->mangled_name = m->mangled_name;
mangled->full_name = make_full_name(t, mangled);
mangled->cap = m->cap;
mangled->r_fun = ast_dup(m->r_fun);
mangled->typeargs = ast_dup(m->typeargs);
mangled->forwarding = true;
mangled->param_count = m->param_count;
mangled->params = (reach_param_t*)ponyint_pool_alloc_size(
mangled->param_count * sizeof(reach_param_t));
memcpy(mangled->params, m->params, m->param_count * sizeof(reach_param_t));
mangled->result = m->result;
// Add to the mangled table only.
reach_mangled_put(&n2->r_mangled, mangled);
}
示例11: doc_list_add
// Add the given AST to the given list, under the specified name
static void doc_list_add(ast_list_t* list, ast_t* ast, const char* name)
{
assert(list != NULL);
assert(ast != NULL);
ast_list_t* n = POOL_ALLOC(ast_list_t);
n->ast = ast;
n->name = name;
n->next = NULL;
// Find where to add name in sorted list
ast_list_t* prev = list;
for(ast_list_t* p = prev->next; p != NULL; prev = p, p = p->next)
{
assert(p->name != NULL);
if(strcmp(p->name, name) > 0)
{
// Add new node before p
n->next = p;
prev->next = n;
return;
}
}
// Add new node at end of list
prev->next = n;
}
示例12: add_method
static void add_method(reachable_method_stack_t** s,
reachable_type_t* t, const char* name, ast_t* typeargs)
{
reachable_method_name_t* n = reach_method_name(t, name);
if(n == NULL)
{
n = POOL_ALLOC(reachable_method_name_t);
n->name = name;
reachable_methods_init(&n->r_methods, 0);
reachable_method_names_put(&t->methods, n);
}
add_rmethod(s, t, n, typeargs);
// Add to subtypes if we're an interface or trait.
ast_t* def = (ast_t*)ast_data(t->type);
switch(ast_id(def))
{
case TK_INTERFACE:
case TK_TRAIT:
{
size_t i = HASHMAP_BEGIN;
reachable_type_t* t2;
while((t2 = reachable_type_cache_next(&t->subtypes, &i)) != NULL)
add_method(s, t2, name, typeargs);
break;
}
default: {}
}
}
示例13: init
static proto_t* init()
{
proto_t* p = POOL_ALLOC(proto_t);
proto_reset(p);
return p;
}
示例14: addTokenWithStr
/* 7.7 */
SWmlToken * addTokenWithStr(SDocData *data,
UINT16 code,
PString str,
ESite site)
{
/*
* Append a new node for 'code' and 'str' to the list of WML tokens.
* If str has never been seen before, create a new entry for it to remember,
* otherwise treat the string entry as going to string table of the
* output stream.
* Note: site==STR_IN_TABLE only when it was called for unknown element
* or attribute.
*---------------------------------------------------------------------------
*/
/* Data Structures */
SWmlToken * _node;
SWmlString * _strEntry = str ? lookupString(data,str) : 0;
/* Code */
if(site==STR_OPAQUE_DATE && str && STR_LEN(str)) {
POOL_ALLOC(DOCPOOL, _strEntry);
_strEntry->m_string = strXDup(str,DOCPOOL);
_strEntry->m_site = STR_OPAQUE_DATE;
_strEntry->m_offset = ~0;
SLL_INSERT(data->m_stringTable[0], _strEntry);
}
else if(_strEntry) { /* it has been seen */
appendToTbl(data,_strEntry, 0); /* 0: try to insert */
}
else if(str) {
_strEntry = insertString(data,str);
if(site==STR_IN_TABLE) {
appendToTbl(data,_strEntry, 1); /* 1: must insert */
}
}
/* If _strEntry is still NULL, it behaves as 'addToken'. */
POOL_ALLOC(DOCPOOL, _node);
_node->m_code = code;
_node->m_strEntry = _strEntry;
FIFO_INSERT(data->m_tokenList, _node);
return _node;
}
示例15: flag_dup
static flag_t* flag_dup(flag_t* flag)
{
assert(flag != NULL);
flag_t* f = POOL_ALLOC(flag_t);
memcpy(f, flag, sizeof(flag_t));
return f;
}