这篇教程C++ ALLOC_N函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ALLOC_N函数的典型用法代码示例。如果您正苦于以下问题:C++ ALLOC_N函数的具体用法?C++ ALLOC_N怎么用?C++ ALLOC_N使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ALLOC_N函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cont_capturestatic VALUEcont_capture(volatile int *stat){ rb_context_t *cont; rb_thread_t *th = GET_THREAD(); volatile VALUE contval; THREAD_MUST_BE_RUNNING(th); rb_vm_stack_to_heap(th); cont = cont_new(rb_cContinuation); contval = cont->self;#ifdef CAPTURE_JUST_VALID_VM_STACK cont->vm_stack_slen = th->cfp->sp + th->mark_stack_len - th->stack; cont->vm_stack_clen = th->stack + th->stack_size - (VALUE*)th->cfp; cont->vm_stack = ALLOC_N(VALUE, cont->vm_stack_slen + cont->vm_stack_clen); MEMCPY(cont->vm_stack, th->stack, VALUE, cont->vm_stack_slen); MEMCPY(cont->vm_stack + cont->vm_stack_slen, (VALUE*)th->cfp, VALUE, cont->vm_stack_clen);#else cont->vm_stack = ALLOC_N(VALUE, th->stack_size); MEMCPY(cont->vm_stack, th->stack, VALUE, th->stack_size);#endif cont->saved_thread.stack = 0; cont_save_machine_stack(th, cont); /* backup ensure_list to array for search in another context */ { rb_ensure_list_t *p; int size = 0; rb_ensure_entry_t *entry; for (p=th->ensure_list; p; p=p->next) size++; entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1); for (p=th->ensure_list; p; p=p->next) { if (!p->entry.marker) p->entry.marker = rb_ary_tmp_new(0); /* dummy object */ *entry++ = p->entry; } entry->marker = 0; } if (ruby_setjmp(cont->jmpbuf)) { volatile VALUE value; VAR_INITIALIZED(cont); value = cont->value; if (cont->argc == -1) rb_exc_raise(value); cont->value = Qnil; *stat = 1; return value; } else { *stat = 0; return contval; }}
开发者ID:0x00evil,项目名称:ruby,代码行数:57,
示例2: na_make_view/* * call-seq: * narray.view => narray * * Return view of NArray */VALUEna_make_view(VALUE self){ int i, nd; size_t j; size_t *idx1, *idx2; ssize_t stride; narray_t *na; narray_view_t *na1, *na2; volatile VALUE view; GetNArray(self,na); nd = na->ndim; view = na_s_allocate_view(CLASS_OF(self)); na_copy_flags(self, view); GetNArrayView(view, na2); na_setup_shape((narray_t*)na2, nd, na->shape); na2->stridx = ALLOC_N(stridx_t,nd); switch(na->type) { case NARRAY_DATA_T: case NARRAY_FILEMAP_T: stride = na_get_elmsz(self); for (i=nd; i--;) { SDX_SET_STRIDE(na2->stridx[i],stride); stride *= na->shape[i]; } na2->offset = 0; na2->data = self; break; case NARRAY_VIEW_T: GetNArrayView(self, na1); for (i=0; i<nd; i++) { if (SDX_IS_INDEX(na1->stridx[i])) { idx1 = SDX_GET_INDEX(na1->stridx[i]); idx2 = ALLOC_N(size_t,na1->base.shape[i]); for (j=0; j<na1->base.shape[i]; j++) { idx2[j] = idx1[j]; } SDX_SET_INDEX(na2->stridx[i],idx2); } else { na2->stridx[i] = na1->stridx[i]; } } na2->offset = na1->offset; na2->data = na1->data; break; } return view;}
开发者ID:yui-knk,项目名称:narray,代码行数:60,
示例3: redtree_init_structvoid redtree_init_struct(struct redtree* tree) { tree->tokens = ALLOC_N(redtree_token, INITIAL_TOKEN_COUNT); tree->token_locations = ALLOC_N(struct token_location, INITIAL_TOKEN_COUNT); tree->token_size = INITIAL_TOKEN_COUNT; tree->token_count = 0; tree->sequence = ALLOC_N(redtree_sequence_entry, INITIAL_SEQUENCE_COUNT); tree->sequence_size = INITIAL_SEQUENCE_COUNT; tree->sequence_count = 0; tree->lines = ALLOC_N(VALUE, INITIAL_LINE_COUNT); tree->line_size = INITIAL_LINE_COUNT; tree->line_count = 0; tree->enc = 0;}
开发者ID:michaeledgar,项目名称:redtree,代码行数:13,
示例4: cont_save_machine_stackstatic voidcont_save_machine_stack(rb_thread_t *th, rb_context_t *cont){ size_t size; rb_thread_t *sth = &cont->saved_thread; SET_MACHINE_STACK_END(&th->machine_stack_end);#ifdef __ia64 th->machine_register_stack_end = rb_ia64_bsp();#endif if (th->machine_stack_start > th->machine_stack_end) { size = cont->machine_stack_size = th->machine_stack_start - th->machine_stack_end; cont->machine_stack_src = th->machine_stack_end; } else { size = cont->machine_stack_size = th->machine_stack_end - th->machine_stack_start; cont->machine_stack_src = th->machine_stack_start; } if (cont->machine_stack) { REALLOC_N(cont->machine_stack, VALUE, size); } else { cont->machine_stack = ALLOC_N(VALUE, size); } FLUSH_REGISTER_WINDOWS; MEMCPY(cont->machine_stack, cont->machine_stack_src, VALUE, size);#ifdef __ia64 rb_ia64_flushrs(); size = cont->machine_register_stack_size = th->machine_register_stack_end - th->machine_register_stack_start; cont->machine_register_stack_src = th->machine_register_stack_start; if (cont->machine_register_stack) { REALLOC_N(cont->machine_register_stack, VALUE, size); } else { cont->machine_register_stack = ALLOC_N(VALUE, size); } MEMCPY(cont->machine_register_stack, cont->machine_register_stack_src, VALUE, size);#endif sth->machine_stack_start = sth->machine_stack_end = 0;#ifdef __ia64 sth->machine_register_stack_start = sth->machine_register_stack_end = 0;#endif}
开发者ID:pascalt,项目名称:captalog,代码行数:49,
示例5: na_expand_dims/* * call-seq: * narray.expand_dims(dim) => narray view * * Expand the shape of an array. Insert a new axis with size=1 * at a given dimension. * @param [Integer] dim dimension at which new axis is inserted. * @return [Numo::NArray] result narray view. */VALUEna_expand_dims(VALUE self, VALUE vdim){ int i, j, nd, dim; size_t *shape, *na_shape; stridx_t *stridx, *na_stridx; narray_t *na; narray_view_t *na2; VALUE view; GetNArray(self,na); nd = na->ndim; dim = NUM2INT(vdim); if (dim < -nd-1 || dim > nd) { rb_raise(nary_eDimensionError,"invalid axis (%d for %dD NArray)", dim,nd); } if (dim < 0) { dim += nd+1; } view = na_make_view(self); GetNArrayView(view, na2); shape = ALLOC_N(size_t,nd+1); stridx = ALLOC_N(stridx_t,nd+1); na_shape = na2->base.shape; na_stridx = na2->stridx; for (i=j=0; i<=nd; i++) { if (i==dim) { shape[i] = 1; SDX_SET_STRIDE(stridx[i],0); } else { shape[i] = na_shape[j]; stridx[i] = na_stridx[j]; j++; } } na2->stridx = stridx; xfree(na_stridx); na2->base.shape = shape; xfree(na_shape); na2->base.ndim++; return view;}
开发者ID:yui-knk,项目名称:narray,代码行数:57,
示例6: sp_session_createsp_errorsp_session_create(const sp_session_config *config, sp_session * *sess){ sp_session *session; if (memcmp(config->application_key, "appkey_good", config->application_key_size)) return SP_ERROR_BAD_APPLICATION_KEY; session = *sess = ALLOC(sp_session); session->config.api_version = config->api_version; session->config.cache_location = strclone(config->cache_location); session->config.settings_location = strclone(config->settings_location); session->config.user_agent = strclone(config->user_agent); session->config.callbacks = ALLOC(sp_session_callbacks); session->config.userdata = config->userdata; session->config.application_key = ALLOC_N(byte, config->application_key_size); memcpy((char *) session->config.application_key, config->application_key, config->application_key_size); if (config->callbacks) { MEMCPY((sp_session_callbacks *) session->config.callbacks, config->callbacks, sp_session_callbacks); } // sp_session defaults session->cache_size = 0; // TODO: v0.0.8 (and earlier) directly call `notify_main_thread` callback here, before returning if (config->callbacks && config->callbacks->notify_main_thread) config->callbacks->notify_main_thread(session); return SP_ERROR_OK;}
开发者ID:bok,项目名称:libmockspotify,代码行数:34,
示例7: fa_compile/* Construct a finite automaton from REGEXP and return it in *FA. * * Return NULL if REGEXP is valid, if the regexp REGEXP has syntax errors, * return an exception. */static struct value *str_to_fa(struct info *info, const char *pattern, struct fa **fa) { int error; struct value *exn = NULL; size_t re_err_len; char *re_str, *re_err; error = fa_compile(pattern, strlen(pattern), fa); if (error == REG_NOERROR) return NULL; re_str = escape(pattern, -1); if (re_str == NULL) { FIXME("Out of memory"); } exn = make_exn_value(info, "Invalid regular expression /%s/", re_str); re_err_len = regerror(error, NULL, NULL, 0); if (ALLOC_N(re_err, re_err_len) < 0) { FIXME("Out of memory"); } regerror(error, NULL, re_err, re_err_len); exn_printf_line(exn, "%s", re_err); free(re_str); free(re_err); return exn;}
开发者ID:camptocamp,项目名称:augeas,代码行数:33,
示例8: grpc_rb_hash_convert_to_channel_args0static VALUE grpc_rb_hash_convert_to_channel_args0(VALUE as_value) { ID id_size = rb_intern("size"); VALUE grpc_rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject); channel_convert_params* params = (channel_convert_params*)as_value; size_t num_args = 0; if (!NIL_P(params->src_hash) && TYPE(params->src_hash) != T_HASH) { rb_raise(rb_eTypeError, "bad channel args: got:<%s> want: a hash or nil", rb_obj_classname(params->src_hash)); return Qnil; } if (TYPE(params->src_hash) == T_HASH) { num_args = NUM2INT(rb_funcall(params->src_hash, id_size, 0)); params->dst->num_args = num_args; params->dst->args = ALLOC_N(grpc_arg, num_args); MEMZERO(params->dst->args, grpc_arg, num_args); rb_hash_foreach(params->src_hash, grpc_rb_channel_create_in_process_add_args_hash_cb, Data_Wrap_Struct(grpc_rb_cChannelArgs, GC_NOT_MARKED, GC_DONT_FREE, params->dst)); /* reset num_args as grpc_rb_channel_create_in_process_add_args_hash_cb * decrements it during has processing */ params->dst->num_args = num_args; } return Qnil;}
开发者ID:cluo,项目名称:grpc,代码行数:27,
示例9: thread_recycle_structstatic rb_thread_t *thread_recycle_struct(void){ void *p = ALLOC_N(rb_thread_t, 1); memset(p, 0, sizeof(rb_thread_t)); return p;}
开发者ID:qnighy,项目名称:ruby-1.9.2p0,代码行数:7,
示例10: Buffer_allocstatic VALUE Buffer_alloc(VALUE klass){ msgpack_buffer_t* b = ALLOC_N(msgpack_buffer_t, 1); msgpack_buffer_init(b); return Data_Wrap_Struct(klass, msgpack_buffer_mark, Buffer_free, b);}
开发者ID:josephholsten,项目名称:msgpack-ruby,代码行数:7,
示例11: na_parse_narray_indexstatic voidna_parse_narray_index(VALUE a, int orig_dim, ssize_t size, na_index_arg_t *q){ VALUE idx; narray_t *na; narray_data_t *nidx; size_t k, n; ssize_t *nidxp; GetNArray(a,na); if (NA_NDIM(na) != 1) { rb_raise(rb_eIndexError, "should be 1-d NArray"); } n = NA_SIZE(na); idx = nary_new(cIndex,1,&n); na_store(idx,a); GetNArrayData(idx,nidx); nidxp = (ssize_t*)nidx->ptr; q->idx = ALLOC_N(size_t, n); for (k=0; k<n; k++) { q->idx[k] = na_range_check(nidxp[k], size, orig_dim); } q->n = n; q->beg = 0; q->step = 1; q->reduce = 0; q->orig_dim = orig_dim;}
开发者ID:kou,项目名称:narray,代码行数:29,
示例12: sysconfstatic char *get_home_dir(uid_t uid) { char *strbuf; char *result; struct passwd pwbuf; struct passwd *pw = NULL; long val = sysconf(_SC_GETPW_R_SIZE_MAX); size_t strbuflen = val; if (val < 0) return NULL; if (ALLOC_N(strbuf, strbuflen) < 0) return NULL; if (getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) { free(strbuf); return NULL; } result = strdup(pw->pw_dir); free(strbuf); return result;}
开发者ID:camptocamp,项目名称:augeas-debian,代码行数:25,
示例13: cont_capturestatic VALUEcont_capture(volatile int *stat){ rb_context_t *cont; rb_thread_t *th = GET_THREAD(), *sth; volatile VALUE contval; vm_stack_to_heap(th); cont = cont_new(rb_cContinuation); contval = cont->self; sth = &cont->saved_thread; cont->vm_stack = ALLOC_N(VALUE, th->stack_size); MEMCPY(cont->vm_stack, th->stack, VALUE, th->stack_size); sth->stack = 0; cont_save_machine_stack(th, cont); if (ruby_setjmp(cont->jmpbuf)) { VALUE value; value = cont->value; cont->value = Qnil; *stat = 1; return value; } else { *stat = 0; return cont->self; }}
开发者ID:genki,项目名称:ruby,代码行数:31,
示例14: Ashton_PixelCache_initVALUE Ashton_PixelCache_init(VALUE self, VALUE owner){ PIXEL_CACHE(); pixel_cache->rb_owner = owner; // Different behaviour depending on what the owning class is. if(RTEST(rb_obj_is_kind_of(owner, rb_cTexture))) { // Ashton::Texture pixel_cache->texture_id = NUM2UINT(rb_funcall(owner, rb_intern("id"), 0)); } else if(RTEST(rb_obj_is_kind_of(owner, rb_cImage))) { // Gosu::Image // TODO: this needs to be done completely differently, since the image is a sprite on a texture, 1024x1024. VALUE tex_info = rb_funcall(owner, rb_intern("gl_tex_info"), 0); pixel_cache->texture_id = NUM2UINT(rb_funcall(tex_info, rb_intern("tex_name"), 0)); } else { rb_raise(rb_eTypeError, "Can only cache Gosu::Image or Ashton::Texture objects."); } pixel_cache->width = NUM2UINT(rb_funcall(owner, rb_intern("width"), 0)); pixel_cache->height = NUM2UINT(rb_funcall(owner, rb_intern("height"), 0)); pixel_cache->data = ALLOC_N(Color_i, pixel_cache->width * pixel_cache->height); cache_texture(pixel_cache); return Qnil;}
开发者ID:KajiMaster,项目名称:ashton,代码行数:31,
示例15: ifact_create_itemsstatic VALUEifact_create_items(VALUE self, VALUE ary){ VALUE entry, path, accel, type, func, data, extdata; GtkItemFactoryEntry *entries; guint i, len, n_menu_entries; n_menu_entries = RARRAY_LEN(ary); entries = ALLOC_N(GtkItemFactoryEntry, n_menu_entries); for (i = 0; i < n_menu_entries; i++) { entry = RARRAY_PTR(ary)[i]; len = RARRAY_LEN(entry); Check_Type(entry, T_ARRAY); path = RARRAY_PTR(entry)[0]; type = ((len > 1) ? RARRAY_PTR(entry)[1] : Qnil); accel = ((len > 2) ? RARRAY_PTR(entry)[2] : Qnil); extdata = ((len > 3) ? RARRAY_PTR(entry)[3] : Qnil); func = ((len > 4) ? RARRAY_PTR(entry)[4] : Qnil); data = ((len > 5) ? RARRAY_PTR(entry)[5] : Qnil); create_factory_entry(&entries[i], self, path, type, accel, extdata, func, data); } gtk_item_factory_create_items (_SELF(self), n_menu_entries, entries, NULL); g_free(entries); return self;}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:29,
示例16: pp_leds_allocatestatic VALUEpp_leds_allocate( VALUE klass ){ int ii; ws2811_t *ledstring; ledstring = ALLOC_N( ws2811_t, 1 ); if (!ledstring) { rb_raise(rb_eNoMemError, "could not allocate PixelPi::Leds instance"); } ledstring->freq = WS2811_TARGET_FREQ; ledstring->dmanum = 5; ledstring->device = NULL; for (ii=0; ii<RPI_PWM_CHANNELS; ii++) { ledstring->channel[ii].gpionum = 0; ledstring->channel[ii].count = 0; ledstring->channel[ii].invert = 0; ledstring->channel[ii].brightness = 255; ledstring->channel[ii].leds = NULL; } return Data_Wrap_Struct( klass, NULL, pp_leds_free, ledstring );}
开发者ID:TwP,项目名称:pixel_pi,代码行数:25,
示例17: sp_mock_playlistcontainer_insertstatic sp_errorsp_mock_playlistcontainer_insert(sp_playlistcontainer *pc, int index, sp_playlistcontainer_playlist_t playlist){ sp_playlistcontainer_playlist_t *new_playlists; int num_playlists = sp_playlistcontainer_num_playlists(pc); int new_num_playlists = num_playlists + 1; int i, j; if (index > num_playlists || index < 0) { return SP_ERROR_INDEX_OUT_OF_RANGE; } new_playlists = ALLOC_N(sp_playlistcontainer_playlist_t, new_num_playlists); for (i = 0, j = 0; i < new_num_playlists; i++) { if (i == index) { MEMCPY(&new_playlists[i], &playlist, sp_playlistcontainer_playlist_t); } else { MEMCPY(&new_playlists[i], &pc->playlists[j++], sp_playlistcontainer_playlist_t); } } free(pc->playlists); pc->playlists = new_playlists; pc->num_playlists = new_num_playlists; return SP_ERROR_OK;}
开发者ID:Burgestrand,项目名称:libmockspotify,代码行数:32,
示例18: sp_playlistcontainer_remove_playlistsp_errorsp_playlistcontainer_remove_playlist(sp_playlistcontainer *pc, int index){ sp_playlistcontainer_playlist_t *new_playlists; int num_playlists = sp_playlistcontainer_num_playlists(pc); int new_num_playlists = num_playlists - 1; int i, j; if (index >= num_playlists || index < 0) { return SP_ERROR_INDEX_OUT_OF_RANGE; } new_playlists = ALLOC_N(sp_playlistcontainer_playlist_t, new_num_playlists); for (i = 0, j = 0; i < num_playlists; ++i) { if (i != index) { MEMCPY(&new_playlists[j++], &pc->playlists[i], sp_playlistcontainer_playlist_t); } } free(pc->playlists); pc->playlists = new_playlists; pc->num_playlists = new_num_playlists; return SP_ERROR_OK;}
开发者ID:Burgestrand,项目名称:libmockspotify,代码行数:28,
示例19: rf_extend_if_necessarystatic void rf_extend_if_necessary(RAMFile *rf, int buf_num){ while (rf->bufcnt <= buf_num) { REALLOC_N(rf->buffers, uchar *, (rf->bufcnt + 1)); rf->buffers[rf->bufcnt++] = ALLOC_N(uchar, BUFFER_SIZE); }}
开发者ID:Bira,项目名称:ferret,代码行数:7,
示例20: run_argsstatic int run_args(int argc, char **argv) { size_t len = 0; char *line = NULL; int code; for (int i=0; i < argc; i++) len += strlen(argv[i]) + 1; if (ALLOC_N(line, len + 1) < 0) return -1; for (int i=0; i < argc; i++) { strcat(line, argv[i]); strcat(line, " "); } if (echo_commands) printf("%s%s/n", AUGTOOL_PROMPT, line); code = run_command(line); free(line); if (code >= 0 && auto_save) if (echo_commands) printf("%ssave/n", AUGTOOL_PROMPT); code = run_command("save"); if (code < 0) { code = -1; print_aug_error(); } return (code >= 0 || code == -2) ? 0 : -1;}
开发者ID:camptocamp,项目名称:augeas-debian,代码行数:28,
示例21: Init_postponed_jobstatic voidInit_postponed_job(void){ rb_vm_t *vm = GET_VM(); vm->postponed_job_buffer = ALLOC_N(rb_postponed_job_t, MAX_POSTPONED_JOB); vm->postponed_job_index = 0;}
开发者ID:ksperling,项目名称:ruby,代码行数:7,
示例22: FREEstruct dict *make_dict(char *key, struct skel *skel, struct dict *subdict) { struct dict *dict = NULL; if (ALLOC(dict) < 0) goto error; if (ALLOC_N(dict->nodes, dict_initial_size) < 0) goto error; if (ALLOC(dict->nodes[0]) < 0) goto error; if (ALLOC(dict->nodes[0]->entry) < 0) goto error; dict->size = dict_initial_size; dict->used = 1; dict->nodes[0]->key = key; dict->nodes[0]->entry->skel = skel; dict->nodes[0]->entry->dict = subdict; dict->nodes[0]->mark = dict->nodes[0]->entry; return dict; error: if (dict->nodes) { if (dict->nodes[0]) FREE(dict->nodes[0]->entry); FREE(dict->nodes[0]); } FREE(dict->nodes); FREE(dict); return NULL;}
开发者ID:d11,项目名称:MCECTL,代码行数:29,
示例23: CheckExtension/* Checks if extension is supported by the current OpenGL implementation */GLboolean CheckExtension(const char *name){ const char *extensions; char *name_tmp; int name_len; GLboolean res; extensions = GetOpenglExtensions(); if(extensions==NULL) return GL_FALSE; /* add trailing space */ name_len = strlen(name); name_tmp = ALLOC_N(GLchar,name_len+1+1); /* terminating null and added space */ strcpy(name_tmp,name); name_tmp[name_len] = ' '; /* add space char for search */ name_tmp[name_len+1] = '/0'; if (strstr(extensions,name_tmp)) res = GL_TRUE; else res = GL_FALSE; xfree(name_tmp); return res; }
开发者ID:Trebor777,项目名称:ruby-opengl,代码行数:29,
示例24: r_mpfi_matrix_to_strf_arystatic VALUE r_mpfi_matrix_to_strf_ary (VALUE self, VALUE format_str) { MPFIMatrix *ptr_self; char *tmp_str1, *tmp_str2, *format; int i, j; VALUE *ary, ret_ary; r_mpfi_get_matrix_struct(ptr_self, self); format = StringValuePtr(format_str); ary = ALLOC_N(VALUE, ptr_self->row); for (i = 0; i < ptr_self->row; i++) { ary[i] = rb_ary_new(); } for (i = 0; i < ptr_self->size; i += ptr_self->row) { for (j = 0; j < ptr_self->row; j++) { if (!mpfr_asprintf(&tmp_str1, format, r_mpfi_left_ptr((ptr_self->data + i + j)))) { rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf."); } if (!mpfr_asprintf(&tmp_str2, format, r_mpfi_right_ptr(ptr_self->data + i + j))) { rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf."); } rb_ary_push(ary[j], rb_ary_new3(2, rb_str_new2(tmp_str1), rb_str_new2(tmp_str2))); mpfr_free_str(tmp_str1); mpfr_free_str(tmp_str2); } } ret_ary = rb_ary_new4(ptr_self->row, ary); free(ary); return ret_ary;}
开发者ID:ytaka,项目名称:ruby-mpfi,代码行数:28,
示例25: regexp_concat_nstruct regexp *regexp_concat_n(struct info *info, int n, struct regexp **r) { size_t len = 0; char *pat, *p; for (int i=0; i < n; i++) if (r[i] != NULL) len += strlen(r[i]->pattern->str) + strlen("()"); if (len == 0) return NULL; if (ALLOC_N(pat, len+1) < 0) return NULL; p = pat; for (int i=0; i < n; i++) { if (r[i] == NULL) continue; *p++ = '('; p = stpcpy(p, r[i]->pattern->str); *p++ = ')'; } return make_regexp(info, pat);}
开发者ID:bkearney,项目名称:augeas,代码行数:25,
示例26: strlenchar *unescape(const char *s, int len, const char *extra) { size_t size; const char *n; char *result, *t; int i; if (len < 0 || len > strlen(s)) len = strlen(s); size = 0; for (i=0; i < len; i++, size++) { if (s[i] == '//' && strchr(escape_names, s[i+1])) { i += 1; } else if (s[i] == '//' && extra && strchr(extra, s[i+1])) { i += 1; } } if (ALLOC_N(result, size + 1) < 0) return NULL; for (i = 0, t = result; i < len; i++, size++) { if (s[i] == '//' && (n = strchr(escape_names, s[i+1])) != NULL) { *t++ = escape_chars[n - escape_names]; i += 1; } else if (s[i] == '//' && extra && strchr(extra, s[i+1]) != NULL) { *t++ = s[i+1]; i += 1; } else { *t++ = s[i]; } } return result;}
开发者ID:Mpounta,项目名称:augeas,代码行数:34,
示例27: MessagePack_Unpacker_allocstatic VALUE MessagePack_Unpacker_alloc(VALUE klass){ VALUE obj; msgpack_unpack_t* mp = ALLOC_N(msgpack_unpack_t, 1); obj = Data_Wrap_Struct(klass, MessagePack_Unpacker_mark, MessagePack_Unpacker_free, mp); return obj;}
开发者ID:bcg,项目名称:msgpack,代码行数:8,
示例28: ALLOC_Nary_t *ary_new(void){ ary_t *ary = ALLOC_N(ary_t, 1); ary->count = 0; ary->max = DEFAULT_ENTRY_COUNT; ary->entries = ALLOC_N(int, DEFAULT_ENTRY_COUNT); return ary;}
开发者ID:iSCInc,项目名称:wikitext-to-html-translator,代码行数:8,
示例29: stack_create/* Creates a stack of prof_frame_t to keep track of timings for active methods. */static prof_stack_t *stack_create(){ prof_stack_t *stack = ALLOC(prof_stack_t); stack->start = ALLOC_N(prof_frame_t, INITIAL_STACK_SIZE); stack->ptr = stack->start; stack->end = stack->start + INITIAL_STACK_SIZE; return stack;}
开发者ID:FesterCluck,项目名称:PMOG-OS,代码行数:11,
示例30: ALLOC/** * Allocate a new watchman_t struct * * The struct has a small amount of extra capacity preallocated, and a blank * header that can be filled in later to describe the PDU. */watchman_t *watchman_init() { watchman_t *w = ALLOC(watchman_t); w->cap = WATCHMAN_DEFAULT_STORAGE; w->len = 0; w->data = ALLOC_N(uint8_t, WATCHMAN_DEFAULT_STORAGE); watchman_append(w, WATCHMAN_HEADER, sizeof(WATCHMAN_HEADER) - 1); return w;}
开发者ID:jiayong,项目名称:myvim,代码行数:15,
注:本文中的ALLOC_N函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ALLOC_STRING函数代码示例 C++ ALLOC_INIT_ZVAL函数代码示例 |