这篇教程C++ GC_malloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GC_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ GC_malloc函数的具体用法?C++ GC_malloc怎么用?C++ GC_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GC_malloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ParamPaths_initvoid ParamPaths_init(void) { register int i0, i1; _mid = _register_module(&ParamPaths_md.md, &ParamPaths__NewFilesDesc_td.td); { char *_mem, *_var; _mem = GC_malloc(_not_zero(20)+8); if (!_mem) _new_failed(_P(18198)); _var = _mem+8; ((_Type*)_var)[-1] = &ParamPaths__PathsSectionDesc_td.td; i0 = (int)_var; } ParamPaths__paths = (void*)i0; i1 = (int)ParamPaths__paths; i0 = i1 + 16; *(unsigned char*)i0 = 0; i1 = (int)ParamPaths__paths; i0 = i1 + 12; *(void**)i0 = (void*)0; { char *_mem, *_var; _mem = GC_malloc(_not_zero(20)+8); if (!_mem) _new_failed(_P(18272)); _var = _mem+8; ((_Type*)_var)[-1] = &ParamPaths__NewFilesDesc_td.td; i0 = (int)_var; } ParamPaths__newFiles = (void*)i0; i0 = (int)ParamPaths__paths; i1 = i0 + 16; *(unsigned char*)i1 = 0; i0 = (int)ParamPaths__newFiles; i1 = i0 + 12; *(void**)i1 = (void*)0;}
开发者ID:Classic-Tools,项目名称:ooc-gsa,代码行数:34,
示例2: lstrvec_alloclstrvec* lstrvec_alloc(int size){ lstrvec* vec = GC_malloc(sizeof(lstrvec)); vec->size = size; if (size != 0) vec->xs = GC_malloc(size * sizeof(char*)); return vec;}
开发者ID:NatTuck,项目名称:pocl-0.7x,代码行数:9,
示例3: regmatch_sub_anytimestatic intregmatch_sub_anytime(struct MatchingContext2 *c, Regex *regex, regexchar * pat2, char *str, char *end_p, int iter_limit, int firstp){ switch (c->label) { case 1: goto label1; case 2: goto label2; case 3: goto label3; } c->ctx = GC_malloc(sizeof(struct MatchingContext1)); c->ctx2 = GC_malloc(sizeof(struct MatchingContext2)); c->ctx->label = 0; c->regex = regex; c->n_any = 0; c->str = str; c->firstp = firstp; for (;;) { c->ctx->label = 0; while (regmatch_iter(c->ctx, c->regex->re, c->str, end_p, c->firstp)) { c->n_any = c->ctx->lastpos - c->str; if (c->n_any <= 0) continue; c->firstp = 0; if (RE_MODE(pat2) == RE_ENDMARK) { c->lastpos = c->str + c->n_any; YIELD(1, c, 1); } else if (regmatch(pat2, c->str + c->n_any, end_p, c->firstp, &c->lastpos) == 1) { YIELD(1, c, 2); } if (iter_limit == 1) continue; c->ctx2->label = 0; while (regmatch_sub_anytime(c->ctx2, regex, pat2, c->str + c->n_any, end_p, iter_limit - 1, c->firstp)) { c->lastpos = c->ctx2->lastpos; YIELD(1, c, 3); } } if (c->regex->alt_regex == NULL) break; c->regex = c->regex->alt_regex; } return 0;}
开发者ID:fiery-,项目名称:w3m,代码行数:52,
示例4: alloc_tree_nodeTreeNode*alloc_tree_node(int type){ TreeNode* tn = GC_malloc(sizeof(TreeNode)); tn->type = type; return tn;}
开发者ID:NatTuck,项目名称:snow-proto,代码行数:7,
示例5: strlen/* * GC strdup() */extern char *GC_strdup(const char *str){ size_t len = strlen(str); char *copy = (char *)GC_malloc(len+1); strcpy(copy, str); return copy;}
开发者ID:GJDuck,项目名称:SMCHR,代码行数:10,
示例6: nearest_powerstatic struct stack_block *mem_block_alloc(size_t min_size){ struct stack_block *block; size_t prev_size, alloc_size; prev_size = current_block == NULL ? 0 : current_block->size; alloc_size = nearest_power(prev_size + min_size);#ifndef USE_GC block = malloc(SIZEOF_MEMBLOCK + alloc_size);#else block = GC_malloc(SIZEOF_MEMBLOCK + alloc_size);#endif if (unlikely(block == NULL)) { if (outofmem) { if (min_size > outofmem_area.block.left) abort(); return &outofmem_area.block; } outofmem = TRUE; i_panic("data stack: Out of memory when allocating %" PRIuSIZE_T" bytes", alloc_size + SIZEOF_MEMBLOCK); } block->size = alloc_size; block->left = 0; block->lowwater = block->size; block->next = NULL;#ifdef DEBUG memset(STACK_BLOCK_DATA(block), CLEAR_CHR, alloc_size);#endif return block;}
开发者ID:Distrotech,项目名称:dovecot,代码行数:33,
示例7: i_panicstatic void *pool_system_malloc(pool_t pool ATTR_UNUSED, size_t size){ void *mem;#ifdef DEBUG int old_errno = errno;#endif if (unlikely(size == 0 || size > SSIZE_T_MAX)) i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);#ifndef USE_GC mem = calloc(size, 1);#else mem = GC_malloc(size);#endif if (unlikely(mem == NULL)) { i_fatal_status(FATAL_OUTOFMEM, "pool_system_malloc(%"PRIuSIZE_T "): Out of memory", size); }#ifdef DEBUG /* we rely on errno not changing. it shouldn't. */ i_assert(errno == old_errno);#endif return mem;}
开发者ID:manuelm,项目名称:dovecot,代码行数:25,
示例8: alloc_valuestatic value_t*alloc_value (ptable_t *ptable, size_t size){ value_t *v = GC_malloc (size); v->ptable = ptable; return v;}
开发者ID:Victorlee1988,项目名称:clojurec,代码行数:7,
示例9: ParamPaths__ParsePatterns_PathList_NewPathParamPaths__Path ParamPaths__ParsePatterns_PathList_NewPath(unsigned char* str, int str_0d) { register int i0, i1, i2; { char *_mem, *_var; _mem = GC_malloc(_not_zero(8)+8); if (!_mem) _new_failed(_P(6224)); _var = _mem+8; ((_Type*)_var)[-1] = &ParamPaths__PathDesc_td.td; i0 = (int)_var; } i2 = Strings__Length((const unsigned char*)(int)str, str_0d); i1 = i0 + 4; i2++; { char *_mem, *_var; int* _dim_ptr; if(i2 < 0) _invalid_length(i2, _P(6281)); _mem = GC_malloc_atomic(_not_zero(i2*1)+8); if (!_mem) _new_failed(_P(6244)); _var = _mem+8; _dim_ptr = (void*)(_var-4); *(--_dim_ptr) = i2; i2 = (int)_var; } *(void**)i1 = (void*)i2; i1 = (int)*(void**)i1; i2 = *(int*)(i1-8); _string_copy(i1, (int)str, i2); *(void**)i0 = (void*)0; return (void*)i0;}
开发者ID:Classic-Tools,项目名称:ooc-gsa,代码行数:31,
示例10: switchscm *run_lisp(struct sexp a_sexp) { switch (a_sexp.type) { case LIST:; // Get the first element (which should be a symbol representing a function) and evaluate it scm *callee = run_lisp(a_sexp.list[0]); assert(callee->type == SCM_FN); scm *args = NULL; struct sexp *remaining = a_sexp.list + 1; while (remaining->type != END_OF_LIST) { args = append(args, run_lisp(*remaining)); remaining++; } return callee->fn(args); case SYMBOL:; char *name = a_sexp.symbol; if (strcmp(name, "+") == 0) { return &_plus_scm; } assert(0 && "Stuff ain't implemented yet!"); break; case INTEGER:; scm *val = GC_malloc(sizeof(scm)); val->type = SCM_INT; val->integer = a_sexp.integer; return val; default: assert(0 && "Whoops..."); }}
开发者ID:mystor,项目名称:simple-lisp-parser-in-c,代码行数:33,
示例11: ss_mallocss_INLINEvoid* ss_malloc(size_t s){ ss_malloc_bytes += s; ss_malloc_objects ++; return GC_malloc(s);}
开发者ID:kstephens,项目名称:ss,代码行数:7,
示例12: sizeofvoid *api_call_method(int numargs, void *obj, void *initptr, va_list vl){ ffi_cif cif; ffi_type *args[numargs + 1]; void *values[numargs + 1]; void **val_heap = (void**)GC_malloc((numargs + 1) * sizeof(void*)); /*new void*[numargs + 1];*/ void *rv; args[0] = &ffi_type_pointer; values[0] = &val_heap[0]; for (int i = 0; i < numargs; i++) { args[i + 1] = &ffi_type_pointer; values[i + 1] = (void*)&val_heap[i + 1]; } int rc = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, numargs + 1, &ffi_type_pointer, args); assert(rc == FFI_OK); val_heap[0] = (void*)obj; for (int i = 0; i < numargs; i++) { val_heap[i + 1] = va_arg(vl, void*); } ffi_call(&cif, (void(*)())initptr, &rv, values); va_end(vl); GC_free(val_heap); /*delete[] val_heap;*/ return rv;}
开发者ID:tmiw,项目名称:kite-llvm,代码行数:27,
示例13: START_TESTEND_TESTSTART_TEST(test_message_send) { message * msg; int * sock = GC_malloc(sizeof(int) * 2); socketpair(AF_UNIX, SOCK_STREAM, 0, sock); msg = message_create_echo(MESSAGE_TYPE_REQUEST, "hey"); message_send(sock[0], msg); char * header_buf = GC_malloc(8); char * data = GC_malloc(7); ck_assert_int_eq(recv(sock[1], header_buf, 8, MSG_DONTWAIT), 8); ck_assert_int_eq(memcmp(header_buf, "/x00/x00/x00/x07/xfb/x65/x78/xa3", 8), 0); ck_assert_int_eq(recv(sock[1], data, 7, MSG_DONTWAIT), 7); ck_assert_int_eq(memcmp(data, "/x93/x00/x01/xa3hey", 7), 0);}
开发者ID:NightBlues,项目名称:cbot,代码行数:16,
示例14: merge_capssinfo_t __init_new_thread_stack (caps_t c, int len,void *(*f)(void *) , void *targ,int arg_len) { len = merge_caps(c,len); // sum caps // it should be at least 16 or we'll be ssinfo_t ss = __get_stack_size(len,arg_len,stack_space); sinfo_t i = (sinfo_t) GC_malloc(ss.real_size); i->tid = _next_tid(); i->thread = f; i->info = ss; i->h = create_hashtable(25); // fprintf(stderr,"/nthread_malloc: %p", i); memcpy(i+1,targ,arg_len); struct _XTreeHandle *r = (struct _XTreeHandle *) (((char *)(i+1)) + arg_len); // fill-in the new tree and transfer capabilities __treecopy(c,r,len,i->tid,&i->h); // set stack guard page so as to handle, page faults. // Here we simply quit.// char *guard = (char *) ALIGN_PG(((char *) i) + ss.end_offset);// if(mprotect(guard,1024,1))// errquit("__init_new_thread: mprotect failed"); //i->info.end_offset = (unsigned long long)guard - // (unsigned long long)i; //assert(i->info.end_offset+1024 <= i->info.real_size); return i;}
开发者ID:pgerakios,项目名称:Concurrent-Cyclone-with-inference,代码行数:32,
示例15: GC_local_mallocGC_PTR GC_local_malloc(size_t bytes){ if (EXPECT(!SMALL_ENOUGH(bytes),0)) { return(GC_malloc(bytes)); } else { int index = INDEX_FROM_BYTES(bytes); ptr_t * my_fl; ptr_t my_entry;# if defined(REDIRECT_MALLOC) && !defined(USE_PTHREAD_SPECIFIC) GC_key_t k = GC_thread_key;# endif void * tsd;# if defined(REDIRECT_MALLOC) && !defined(USE_PTHREAD_SPECIFIC) if (EXPECT(0 == k, 0)) { /* This can happen if we get called when the world is */ /* being initialized. Whether we can actually complete */ /* the initialization then is unclear. */ GC_init_parallel(); k = GC_thread_key; }# endif tsd = GC_getspecific(GC_thread_key);# ifdef GC_ASSERTIONS LOCK(); GC_ASSERT(tsd == (void *)GC_lookup_thread(pthread_self())); UNLOCK();# endif my_fl = ((GC_thread)tsd) -> normal_freelists + index; my_entry = *my_fl; if (EXPECT((word)my_entry >= HBLKSIZE, 1)) { ptr_t next = obj_link(my_entry); GC_PTR result = (GC_PTR)my_entry; *my_fl = next; obj_link(my_entry) = 0; PREFETCH_FOR_WRITE(next); return result; } else if ((word)my_entry - 1 < DIRECT_GRANULES) { *my_fl = my_entry + index + 1; return GC_malloc(bytes); } else { GC_generic_malloc_many(BYTES_FROM_INDEX(index), NORMAL, my_fl); if (*my_fl == 0) return GC_oom_fn(bytes); return GC_local_malloc(bytes); } }}
开发者ID:fenghaitao,项目名称:Harpoon,代码行数:47,
示例16: allocate static void* allocate(std::size_t n) { IMMER_GC_INIT_GUARD_; auto p = GC_malloc(n); if (IMMER_UNLIKELY(!p)) throw std::bad_alloc{}; return p; }
开发者ID:dashpay,项目名称:dash,代码行数:8,
示例17: box_DFGEN box_DF(double a) { dfloat_t *val = GC_malloc(sizeof(dfloat_t)); val->descriptor = dfloat_key; val->dval = a; return (GEN)val;}
开发者ID:cahirwpz,项目名称:phd,代码行数:8,
示例18: new/* This makes sure that the garbage collector sees all allocations, even those that we can't be bothered collecting, especially standard STL objects */void* operator new(size_t n){#ifdef DONT_COLLECT_STL return GC_malloc_uncollectable(n); // Don't collect, but mark#else return GC_malloc(n); // Collect everything#endif}
开发者ID:zecke,项目名称:boomerang,代码行数:10,
示例19: box_SIGEN box_SI(LONG a) { integer_t *val = GC_malloc(sizeof(integer_t)); val->descriptor = integer_key; val->ival = a; return (GEN)val;}
开发者ID:cahirwpz,项目名称:phd,代码行数:8,
示例20: message_createmessage * message_create(message_type type, message_action action) { message * mess = GC_malloc(sizeof(message)); mess->type = type; mess->action = action; mess->to_msgpack = message_to_msgpack_base; return mess;}
开发者ID:NightBlues,项目名称:cbot,代码行数:8,
示例21: alloc_ptablestatic ptable_t*alloc_ptable (int type){ ptable_t *ptable = GC_malloc (sizeof (ptable_t)); ptable->type = type; ptable->entries = &empty_ptable_entry; return ptable;}
开发者ID:Victorlee1988,项目名称:clojurec,代码行数:8,
示例22: objc_mallocvoid *objc_malloc (size_t size){ void *res = (void *)(GC_malloc (size)); if (! res) _objc_abort ("Virtual memory exhausted/n"); return res;}
开发者ID:AlexMioMio,项目名称:gcc,代码行数:8,
示例23: alloc_envstatic environment_t*alloc_env (environment_t *up, int num_bindings){ environment_t *env = GC_malloc (sizeof (environment_t) + num_bindings * sizeof (value_t*)); env->up = up; env->num_bindings = num_bindings; return env;}
开发者ID:Victorlee1988,项目名称:clojurec,代码行数:8,
示例24: Tunsigned long int* T() { unsigned long int* aux; aux = GC_malloc(SIZE, sizeof(unsigned long int) ); int i; for(i = 0; i < SIZE; i++) { aux[i] = Z( i ); } return init( aux , 0 , (unsigned long int) 9876 );}
开发者ID:Gaspi,项目名称:pvs2C,代码行数:9,
示例25: CONSGEN CONS(GEN fst, GEN snd) { cons_t *val = GC_malloc(sizeof(cons_t)); val->descriptor = cons_key; val->fst = fst; val->snd = snd; return (GEN)val;}
开发者ID:cahirwpz,项目名称:phd,代码行数:9,
示例26: smap_allocsmap*smap_alloc(int64_t size, stype* ktype, stype* vtype){ smap* map = GC_malloc(sizeof(smap)); map->size = size; map->ktype = ktype; map->vtype = vtype; if (size == 0) { map->data = 0 } else { int64_t item_size = ktype->size + vtype->size; map->data = GC_malloc(2 * item_size); } return map;}
开发者ID:NatTuck,项目名称:snow-proto,代码行数:18,
示例27: GC_mallocvoid *safe_malloc(size_t size) { void *result = GC_malloc(size); if(!result) { perror("malloc"); exit(EXIT_FAILURE); } return result;}
开发者ID:rpedde,项目名称:minischeme,代码行数:9,
示例28: make_string_from_unicharstatic value_t*make_string_from_unichar (gunichar c){ gchar *buf = GC_malloc (7); string_t *s = (string_t*) alloc_value (PTABLE_NAME (cljc_DOT_core_SLASH_String), sizeof (string_t)); buf [g_unichar_to_utf8 (c, buf)] = '/0'; s->utf8 = buf; return &s->val;}
开发者ID:Victorlee1988,项目名称:clojurec,代码行数:9,
示例29: alloc_half_edgehalf_edge alloc_half_edge(void* v) { half_edge e = (half_edge) GC_malloc(sizeof(struct half_edge_cell)); e->vertex = v; e->opp = NULL; e->next = NULL; e->prev = NULL; e->visited = 0; return e;}
开发者ID:Gnuk,项目名称:m1_infographie,代码行数:9,
示例30: jsortunsigned long int jsort() { unsigned long int* aux; aux = GC_malloc(SIZE, sizeof(unsigned long int) ); int i; for(i = 0; i < SIZE; i++) { aux[i] = J( i ); } return insort( aux )[0];}
开发者ID:Gaspi,项目名称:pvs2C,代码行数:9,
注:本文中的GC_malloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GC_printf函数代码示例 C++ GC_get_heap_size函数代码示例 |