• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ POOL_ALLOC函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了POOL_ALLOC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:andymcn,项目名称:ponyc,代码行数:15,代码来源:buildflagset.c


示例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;
}
开发者ID:cyisfor,项目名称:ponyc,代码行数:29,代码来源:cycle.c


示例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;
}
开发者ID:dipinhora,项目名称:ponyc,代码行数:7,代码来源:package.c


示例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;
}
开发者ID:Perelandric,项目名称:ponyc,代码行数:7,代码来源:error.c


示例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;
}
开发者ID:danielaRiesgo,项目名称:ponyc,代码行数:60,代码来源:serialise.c


示例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);
  }
}
开发者ID:DevL,项目名称:ponyc,代码行数:35,代码来源:reach.c


示例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;
}
开发者ID:killerswan,项目名称:ponyc,代码行数:33,代码来源:event.c


示例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;
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:28,代码来源:wmlstruc.c


示例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;
}
开发者ID:Potpourri,项目名称:ponyc,代码行数:30,代码来源:builder.c


示例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);
}
开发者ID:Sendence,项目名称:ponyc,代码行数:34,代码来源:reach.c


示例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;
}
开发者ID:shlomif,项目名称:ponyc,代码行数:30,代码来源:docgen.c


示例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: {}
  }
}
开发者ID:DevL,项目名称:ponyc,代码行数:35,代码来源:reach.c


示例13: init

static proto_t* init()
{
  proto_t* p = POOL_ALLOC(proto_t);

  proto_reset(p);

  return p;
}
开发者ID:abingham,项目名称:ponyc,代码行数:8,代码来源:proto.c


示例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;
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:47,代码来源:wmlstruc.c


示例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;
}
开发者ID:andymcn,项目名称:ponyc,代码行数:8,代码来源:buildflagset.c


示例16: token_dup

token_t* token_dup(token_t* token)
{
  assert(token != NULL);
  token_t* t = POOL_ALLOC(token_t);
  memcpy(t, token, sizeof(token_t));
  t->printed = NULL;
  return t;
}
开发者ID:Potpourri,项目名称:ponyc,代码行数:8,代码来源:token.c


示例17: reach_new

reach_t* reach_new()
{
  reach_t* r = POOL_ALLOC(reach_t);
  r->stack = NULL;
  r->next_type_id = 0;
  reach_types_init(&r->types, 64);
  return r;
}
开发者ID:Sendence,项目名称:ponyc,代码行数:8,代码来源:reach.c


示例18: package_add_magic

void package_add_magic(const char* path, const char* src)
{
  magic_package_t* n = POOL_ALLOC(magic_package_t);
  n->path = stringtab(path);
  n->src = src;
  n->next = magic_packages;
  magic_packages = n;
}
开发者ID:lzpfmh,项目名称:ponyc,代码行数:8,代码来源:package.c


示例19: codegen_setlocal

void codegen_setlocal(compile_t* c, const char* name, LLVMValueRef alloca)
{
  compile_local_t* p = POOL_ALLOC(compile_local_t);
  p->name = name;
  p->alloca = alloca;

  compile_locals_put(&c->frame->locals, p);
}
开发者ID:dckc,项目名称:ponyc,代码行数:8,代码来源:codegen.c


示例20: parse

bool parse(ast_t* package, source_t* source, rule_t start,
  const char* expected)
{
  assert(package != NULL);
  assert(source != NULL);
  assert(expected != NULL);

  // Open the lexer
  lexer_t* lexer = lexer_open(source);

  if(lexer == NULL)
    return false;

  // Create a parser and attach the lexer
  parser_t* parser = POOL_ALLOC(parser_t);
  parser->source = source;
  parser->lexer = lexer;
  parser->token = lexer_next(lexer);
  parser->last_matched = NULL;
  parser->last_token_line = 0;
  parser->next_flags = 0;
  parser->failed = false;

  // Parse given start rule
  builder_fn_t build_fn;
  ast_t* ast = start(parser, &build_fn, expected);

  if(ast == PARSE_ERROR)
    ast = NULL;

  if(ast == RULE_NOT_FOUND)
  {
    syntax_error(parser, expected, NULL, NULL);
    ast = NULL;
  }

  if(parser->failed)
  {
    ast_free(ast);
    ast = NULL;
  }

  lexer_close(lexer);
  token_free(parser->token);
  POOL_FREE(parser_t, parser);

  if(ast == NULL)
  {
    source_close(source);
    return false;
  }

  assert(ast_id(ast) == TK_MODULE);
  assert(ast_data(ast) == NULL);
  ast_setdata(ast, source);
  ast_add(package, ast);
  return true;
}
开发者ID:DevL,项目名称:ponyc,代码行数:58,代码来源:parserapi.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ POP函数代码示例发布时间:2022-05-30
下一篇:
C++ POLYBENCH_FREE_ARRAY函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap