您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ yajl_free函数代码示例

51自学网 2021-06-03 11:54:15
  C++
这篇教程C++ yajl_free函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了yajl_free函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: calloc

struct aws_dynamo_create_table_response*aws_dynamo_parse_create_table_response(const char *response, int response_len){	yajl_handle hand;	yajl_status stat;	struct ctx _ctx = { 0 };	_ctx.r = calloc(sizeof(*(_ctx.r)), 1);	if (_ctx.r == NULL) {		Warnx("aws_dynamo_parse_create_table_response: response alloc failed.");		return NULL;	}#if YAJL_MAJOR == 2	hand = yajl_alloc(&handle_callbacks, NULL, &_ctx);	yajl_parse(hand, response, response_len);	stat = yajl_complete_parse(hand);#else	hand = yajl_alloc(&handle_callbacks, NULL, NULL, &_ctx);	yajl_parse(hand, response, response_len);	stat = yajl_parse_complete(hand);#endif	if (stat != yajl_status_ok) {		unsigned char *str = yajl_get_error(hand, 1, response, response_len);		Warnx("aws_dynamo_parse_create_table_response: json parse failed, '%s'", (const char *)str);		yajl_free_error(hand, str);		yajl_free(hand);		aws_dynamo_free_create_table_response(_ctx.r);		return NULL;	}	yajl_free(hand);	return _ctx.r;}
开发者ID:Flightradar24,项目名称:aws_dynamo,代码行数:35,


示例2: cj_curl_perform

static int cj_curl_perform (cj_t *db, CURL *curl) /* {{{ */{  int status;  long rc;  char *url;  yajl_handle yprev = db->yajl;  db->yajl = yajl_alloc (&ycallbacks, NULL, NULL, (void *)db);  if (db->yajl == NULL)  {    ERROR ("curl_json plugin: yajl_alloc failed.");    db->yajl = yprev;    return (-1);  }  url = NULL;  curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);  status = curl_easy_perform (curl);  if (status != 0)  {    ERROR ("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)",           status, db->curl_errbuf, (url != NULL) ? url : "<null>");    yajl_free (db->yajl);    db->yajl = yprev;    return (-1);  }  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &rc);  /* The response code is zero if a non-HTTP transport was used. */  if ((rc != 0) && (rc != 200))  {    ERROR ("curl_json plugin: curl_easy_perform failed with "        "response code %ld (%s)", rc, url);    yajl_free (db->yajl);    db->yajl = yprev;    return (-1);  }  status = yajl_parse_complete (db->yajl);  if (status != yajl_status_ok)  {    unsigned char *errmsg;    errmsg = yajl_get_error (db->yajl, /* verbose = */ 0,        /* jsonText = */ NULL, /* jsonTextLen = */ 0);    ERROR ("curl_json plugin: yajl_parse_complete failed: %s",        (char *) errmsg);    yajl_free_error (db->yajl, errmsg);    yajl_free (db->yajl);    db->yajl = yprev;    return (-1);  }  yajl_free (db->yajl);  db->yajl = yprev;  return (0);} /* }}} int cj_curl_perform */
开发者ID:gnosek,项目名称:collectd,代码行数:59,


示例3: yajl_tree_parse_options

yajl_val yajl_tree_parse_options (const char *input,                                   char *error_buffer, size_t error_buffer_size,                                   yajl_tree_option options){    static const yajl_callbacks callbacks =        {            /* null        = */ handle_null,            /* boolean     = */ handle_boolean,            /* integer     = */ NULL,            /* double      = */ NULL,            /* number      = */ handle_number,            /* string      = */ handle_string,            /* start map   = */ handle_start_map,            /* map key     = */ handle_string,            /* end map     = */ handle_end_map,            /* start array = */ handle_start_array,            /* end array   = */ handle_end_array        };    yajl_handle handle;    yajl_status status;    char * internal_err_str;	context_t ctx = { NULL, NULL, NULL, 0 };	ctx.errbuf = error_buffer;	ctx.errbuf_size = error_buffer_size;    if (error_buffer != NULL)        memset (error_buffer, 0, error_buffer_size);    handle = yajl_alloc (&callbacks, NULL, &ctx);    yajl_config(handle, yajl_allow_comments,            (options & yajl_tree_option_dont_allow_comments) ? 0 : 1);    yajl_config(handle, yajl_allow_trailing_separator,            (options & yajl_tree_option_allow_trailing_separator) ? 1 : 0);    status = yajl_parse(handle,                        (unsigned char *) input,                        strlen (input));    status = yajl_complete_parse (handle);    if (status != yajl_status_ok) {        if (error_buffer != NULL && error_buffer_size > 0) {               internal_err_str = (char *) yajl_get_error(handle, 1,                     (const unsigned char *) input,                     strlen(input));             snprintf(error_buffer, error_buffer_size, "%s", internal_err_str);             YA_FREE(&(handle->alloc), internal_err_str);        }        while (ctx.stack) {            yajl_tree_free(context_pop(&ctx));        }        yajl_free (handle);        return NULL;    }    yajl_free (handle);    return (ctx.root);}
开发者ID:ludocode,项目名称:yajl,代码行数:58,


示例4: cj_perform

static int cj_perform (cj_t *db) /* {{{ */{    int status;    yajl_handle yprev = db->yajl;    db->yajl = yajl_alloc (&ycallbacks,#if HAVE_YAJL_V2                           /* alloc funcs = */ NULL,#else                           /* alloc funcs = */ NULL, NULL,#endif                           /* context = */ (void *)db);    if (db->yajl == NULL)    {        ERROR ("curl_json plugin: yajl_alloc failed.");        db->yajl = yprev;        return (-1);    }    if (db->url)        status = cj_curl_perform (db);    else        status = cj_sock_perform (db);    if (status < 0)    {        yajl_free (db->yajl);        db->yajl = yprev;        return (-1);    }#if HAVE_YAJL_V2    status = yajl_complete_parse(db->yajl);#else    status = yajl_parse_complete(db->yajl);#endif    if (status != yajl_status_ok)    {        unsigned char *errmsg;        errmsg = yajl_get_error (db->yajl, /* verbose = */ 0,                                 /* jsonText = */ NULL, /* jsonTextLen = */ 0);        ERROR ("curl_json plugin: yajl_parse_complete failed: %s",               (char *) errmsg);        yajl_free_error (db->yajl, errmsg);        yajl_free (db->yajl);        db->yajl = yprev;        return (-1);    }    yajl_free (db->yajl);    db->yajl = yprev;    return (0);} /* }}} int cj_perform */
开发者ID:karcaw,项目名称:collectd,代码行数:53,


示例5: mParser_do_yajl_parse

static VALUE mParser_do_yajl_parse(VALUE self, VALUE str, VALUE yajl_opts) {  yajl_handle hand;  yajl_status stat;  unsigned char *err;  volatile CTX ctx;  rb_ivar_set(self, rb_intern("key"), Qnil);  rb_ivar_set(self, rb_intern("stack"), rb_ary_new());  rb_ivar_set(self, rb_intern("key_stack"), rb_ary_new());  ctx.self = self;  ctx.symbolizeKeys = get_opts_key(self, "symbolize_keys");  ctx.uniqueKeyChecking = get_opts_key(self, "unique_key_checking");  hand = yajl_alloc(&callbacks, NULL, (void *)&ctx);  if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_comments"))) == Qtrue) {    yajl_config(hand, yajl_allow_comments, 1);  }  if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_dont_validate_strings"))) == Qtrue) {    yajl_config(hand, yajl_dont_validate_strings, 1);  }  if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_trailing_garbage"))) == Qtrue) {    yajl_config(hand, yajl_allow_trailing_garbage, 1);  }  if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_multiple_values"))) == Qtrue) {    yajl_config(hand, yajl_allow_multiple_values, 1);  }  if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_partial_values"))) == Qtrue) {    yajl_config(hand, yajl_allow_partial_values, 1);  }  if ((stat = yajl_parse(hand, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str))) != yajl_status_ok) {    err = yajl_get_error(hand, 1, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));    goto raise;  }  if ((stat = yajl_complete_parse(hand)) != yajl_status_ok) {    err = yajl_get_error(hand, 1, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));    goto raise;  }  yajl_free(hand);  return rb_ary_pop(rb_ivar_get(self, rb_intern("stack")));raise:  if (hand) {    yajl_free(hand);  }  rb_raise(cParseError, "%s", err);}
开发者ID:Rosiv,项目名称:omnibus-portable,代码行数:49,


示例6: sl_json_parse

static SLVALsl_json_parse(sl_vm_t* vm, SLVAL self, size_t argc, SLVAL* argv){    sl_string_t* str = sl_get_string(vm, argv[0]);    json_parse_t json;    yajl_alloc_funcs alloc_funcs = {        sl_yajl_alloc,        sl_yajl_realloc,        sl_yajl_free,        NULL    };    alloc_funcs.ctx = vm->arena;    json.vm = vm;    json.max_depth = 32;    json.stack_len = 0;    json.stack_cap = 32;    json.stack = sl_alloc(vm->arena, sizeof(SLVAL) * json.stack_cap);    json.type_stack = sl_alloc(vm->arena, json.stack_cap);    if(argc > 1) {        json.max_depth = sl_get_int(sl_expect(vm, argv[1], vm->lib.Int));    }        json.yajl = yajl_alloc(&callbacks, &alloc_funcs, &json);    sl_json_parse_check_error(vm, str, &json, yajl_parse(json.yajl, str->buff, str->buff_len));    sl_json_parse_check_error(vm, str, &json, yajl_complete_parse(json.yajl));    yajl_free(json.yajl);    /* must've been OK! */    return json.stack[0];            (void)self;}
开发者ID:Hmaal,项目名称:slash,代码行数:32,


示例7: parse_json_header

/* * Parse the JSON protocol header to determine protocol version and features. * In case the buffer does not contain a valid header (invalid JSON, or no * version field found), the 'correct' field of the returned header is set to * false. The amount of bytes consumed by parsing the header is returned in * *consumed (if non-NULL). * */void parse_json_header(i3bar_child *child, const unsigned char *buffer, int length, unsigned int *consumed) {    static yajl_callbacks version_callbacks = {        .yajl_boolean = header_boolean,        .yajl_integer = header_integer,        .yajl_map_key = &header_map_key,    };    child_init(child);    current_key = NO_KEY;    yajl_handle handle = yajl_alloc(&version_callbacks, NULL, child);    /* Allow trailing garbage. yajl 1 always behaves that way anyways, but for     * yajl 2, we need to be explicit. */    yajl_config(handle, yajl_allow_trailing_garbage, 1);    yajl_status state = yajl_parse(handle, buffer, length);    if (state != yajl_status_ok) {        child_init(child);        if (consumed != NULL)            *consumed = 0;    } else {        if (consumed != NULL)            *consumed = yajl_get_bytes_consumed(handle);    }    yajl_free(handle);}
开发者ID:Acidburn0zzz,项目名称:i3,代码行数:36,


示例8: yajl_parser_wrapper_free

void yajl_parser_wrapper_free(void * wrapper) {    yajl_parser_wrapper * w = wrapper;    if (w) {        yajl_free(w->parser);        free(w);    }}
开发者ID:fcheung,项目名称:yajl-ruby,代码行数:7,


示例9: yajl_free_error

    ~YajlHandle() {        if (errstring)            yajl_free_error(hand, errstring);        if (hand)            yajl_free(hand);    }
开发者ID:erg,项目名称:noise,代码行数:7,


示例10: parse_outputs_json

/* * Start parsing the received JSON string * */void parse_outputs_json(char *json) {    struct outputs_json_params params;    params.outputs_walk = NULL;    params.cur_key = NULL;    params.json = json;    params.in_rect = false;    yajl_handle handle;    yajl_status state;    handle = yajl_alloc(&outputs_callbacks, NULL, (void *)&params);    state = yajl_parse(handle, (const unsigned char *)json, strlen(json));    /* FIXME: Proper errorhandling for JSON-parsing */    switch (state) {        case yajl_status_ok:            break;        case yajl_status_client_canceled:        case yajl_status_error:            ELOG("Could not parse outputs reply!/n");            exit(EXIT_FAILURE);            break;    }    yajl_free(handle);}
开发者ID:fernandoataoldotcom,项目名称:i3,代码行数:30,


示例11: _j4status_i3bar_output_uninit

static void_j4status_i3bar_output_uninit(J4statusPluginContext *context){    yajl_free(context->json_handle);    g_free(context);}
开发者ID:sardemff7,项目名称:j4status,代码行数:7,


示例12: yajl_alloc

static const char *parse_json(state_t *st, unsigned char *buf, size_t len){  yajl_parser_config cfg = {    1, /* allow comments */    0  /* don't check UTF-8 */  };  yajl_handle yh;  yajl_status ys;  const char *err=NULL;  alloc_funcs.ctx = st->env; /* will be passed to alloc funcs */  yh = yajl_alloc(&callbacks, &cfg, &alloc_funcs, st);  ys = yajl_parse(yh, buf, len);  if (ys == yajl_status_insufficient_data) {    ys = yajl_parse_complete(yh);  }  if (ys == yajl_status_insufficient_data) {    err = "unexpected end of document";  } else if (ys != yajl_status_ok) {    unsigned char *msg = yajl_get_error(yh, 0, NULL, 0);    strncpy(st->errmsg, (char *)msg, sizeof(st->errmsg)-1);    yajl_free_error(yh, msg);    st->errmsg[sizeof(st->errmsg)] = 0;    err = st->errmsg;  }  yajl_free(yh);  return err;}
开发者ID:Waterback,项目名称:Erlang-and-OTP-in-Action-Source,代码行数:28,


示例13: parse_config_json

/* * Start parsing the received bar configuration json-string * */void parse_config_json(char *json) {    yajl_handle handle;    yajl_status state;#if YAJL_MAJOR < 2    yajl_parser_config parse_conf = { 0, 0 };    handle = yajl_alloc(&outputs_callbacks, &parse_conf, NULL, NULL);#else    handle = yajl_alloc(&outputs_callbacks, NULL, NULL);#endif    state = yajl_parse(handle, (const unsigned char*) json, strlen(json));    /* FIXME: Proper errorhandling for JSON-parsing */    switch (state) {        case yajl_status_ok:            break;        case yajl_status_client_canceled:#if YAJL_MAJOR < 2        case yajl_status_insufficient_data:#endif        case yajl_status_error:            ELOG("Could not parse config-reply!/n");            exit(EXIT_FAILURE);            break;    }    yajl_free(handle);}
开发者ID:Airblader,项目名称:i3,代码行数:33,


示例14: ReadData

VOID ReadData(REQUEST_CONTEXT* context){	yajl_handle hand;	yajl_parser_config cfg = { 1, 1 };	json_ctx ctx = { 0, 0 };	hand = JSONCodec::AllocateHandle(&cfg, &ctx);	unsigned char temp[BUFFER_SIZE];	DWORD read = 0;	BOOL res = FALSE;	while(true) {		res = WinHttpReadData(context->hRequest, temp, BUFFER_SIZE, &read);		if(!res) {			Log::Error("Error reading response data");			break;		}		if(read == 0)			break;		temp[read] = 0;		yajl_status status = yajl_parse(hand, temp, read);		if(status == yajl_status_error) {			Log::Error("Error parsing response data");			res = FALSE;			break;		}	}	yajl_parse_complete(hand);    yajl_free(hand);	JSONCodec::Decode(ctx.current, context->px);	JSONCodec::FreeJsonValue(ctx.current);}
开发者ID:stier08,项目名称:xlloop,代码行数:32,


示例15: aws_dynamo_parse_put_item_response

struct aws_dynamo_put_item_response * aws_dynamo_parse_put_item_response(const char *response, int response_len, struct aws_dynamo_attribute *attributes, int num_attributes){	yajl_handle hand;	yajl_status stat;	struct put_item_ctx _ctx = { 0 };	_ctx.r = calloc(sizeof(*(_ctx.r)), 1);	if (_ctx.r == NULL) {		Warnx("aws_dynamo_parse_put_item_response: response alloc failed.");		return NULL;	}	if (num_attributes > 0) {		_ctx.r->attributes = malloc(sizeof(*(_ctx.r->attributes)) * num_attributes);		if (_ctx.r->attributes == NULL) {			Warnx("aws_dynamo_parse_put_item_response: attribute alloc failed.");			free(_ctx.r);			return NULL;		}		memcpy(_ctx.r->attributes, attributes, sizeof(*(attributes)) * num_attributes);		_ctx.r->num_attributes = num_attributes;	}#if YAJL_MAJOR == 2	hand = yajl_alloc(&put_item_callbacks, NULL, &_ctx);	yajl_parse(hand, response, response_len);	stat = yajl_complete_parse(hand);#else	hand = yajl_alloc(&put_item_callbacks, NULL, NULL, &_ctx);	yajl_parse(hand, response, response_len);	stat = yajl_parse_complete(hand);#endif	if (stat != yajl_status_ok) {		unsigned char *str =		    yajl_get_error(hand, 1, response, response_len);		Warnx("aws_dynamo_parse_put_item_response: json parse failed, '%s'", (const char *)str);		yajl_free_error(hand, str);		yajl_free(hand);		aws_dynamo_free_put_item_response(_ctx.r);		return NULL;	}	yajl_free(hand);	return _ctx.r;}
开发者ID:Flightradar24,项目名称:aws_dynamo,代码行数:46,


示例16: virJSONValueFromString

/* XXX add an incremental streaming parser - yajl trivially supports it */virJSONValuePtr virJSONValueFromString(const char *jsonstring){    yajl_handle hand;    virJSONParser parser = { NULL, NULL, 0 };    virJSONValuePtr ret = NULL;# ifndef WITH_YAJL2    yajl_parser_config cfg = { 1, 1 };# endif    VIR_DEBUG("string=%s", jsonstring);# ifdef WITH_YAJL2    hand = yajl_alloc(&parserCallbacks, NULL, &parser);    if (hand) {        yajl_config(hand, yajl_allow_comments, 1);        yajl_config(hand, yajl_dont_validate_strings, 0);    }# else    hand = yajl_alloc(&parserCallbacks, &cfg, NULL, &parser);# endif    if (!hand) {        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                       _("Unable to create JSON parser"));        goto cleanup;    }    if (yajl_parse(hand,                   (const unsigned char *)jsonstring,                   strlen(jsonstring)) != yajl_status_ok) {        unsigned char *errstr = yajl_get_error(hand, 1,                                               (const unsigned char*)jsonstring,                                               strlen(jsonstring));        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("cannot parse json %s: %s"),                       jsonstring, (const char*) errstr);        VIR_FREE(errstr);        virJSONValueFree(parser.head);        goto cleanup;    }    ret = parser.head;cleanup:    yajl_free(hand);    if (parser.nstate) {        size_t i;        for (i = 0; i < parser.nstate; i++) {            VIR_FREE(parser.state[i].key);        }        VIR_FREE(parser.state);    }    VIR_DEBUG("result=%p", parser.head);    return ret;}
开发者ID:cardoe,项目名称:libvirt,代码行数:59,


示例17: SLNJSONFilterParserEnd

SLNFilterRef SLNJSONFilterParserEnd(SLNJSONFilterParserRef const parser) {	if(!parser) return NULL;	assertf(parser->JSONParser, "Parser in invalid state");	yajl_status const err = yajl_complete_parse(parser->JSONParser);	yajl_free(parser->JSONParser); parser->JSONParser = NULL;	assertf(-1 == parser->depth, "Parser ended at invalid depth %d", parser->depth);	SLNFilterRef const filter = parser->stack[0];	parser->stack[0] = NULL;	return yajl_status_ok == err ? filter : NULL;}
开发者ID:andreydelpozo2,项目名称:stronglink,代码行数:10,


示例18: sl_json_parse_check_error

static voidsl_json_parse_check_error(sl_vm_t* vm, sl_string_t* str, json_parse_t* json, yajl_status status){    uint8_t* err_str;    SLVAL err;    if(status == yajl_status_client_canceled) {        /* the only reason we'd cancel the parse is if the data structre is too deep */        yajl_free(json->yajl);        sl_throw_message2(vm, vm->store[cJSON_ParseError],            "JSON structure recurses too deep");    }    if(status == yajl_status_error) {        err_str = yajl_get_error(json->yajl, 0, (const uint8_t*)str->buff, (size_t)str->buff_len);        err = sl_make_cstring(vm, (char*)err_str);        yajl_free_error(json->yajl, err_str);        yajl_free(json->yajl);        sl_throw(vm, sl_make_error2(vm, vm->store[cJSON_ParseError], err));    }}
开发者ID:Hmaal,项目名称:slash,代码行数:19,


示例19: json_streamer_destroy

void json_streamer_destroy(struct json_streamer *json){	if (json) {		if (json->yajl)			yajl_free(json->yajl);		if (json->ctx)			free(json->ctx);		free(json);	}}
开发者ID:juaristi,项目名称:appbase-cctv,代码行数:11,


示例20: rest_json_payload_free

static voidrest_json_payload_free(void *f) {  int i;  struct rest_json_payload *json = f;  if(json->parser) yajl_free(json->parser);  if(json->error) free(json->error);  for(i=0;i<MAX_DEPTH;i++)    if(json->keys[i]) free(json->keys[i]);  if(json->last_value) free(json->last_value);  free(json);}
开发者ID:edwardt,项目名称:reconnoiter,代码行数:11,


示例21: jp_destroy

static void jp_destroy(JsonParserCtx *ctx){	while (ctx->nestingChain) {		jp_nesting_chain_head_pop(ctx);	}	JsonElFree(ctx->firstEl);	if (ctx->yajl_handle) {		yajl_free(ctx->yajl_handle);	}}
开发者ID:carlojasmin,项目名称:dynamicipupdate,代码行数:11,


示例22: parseSampleFromFile

int parseSampleFromFile(Sample *sample, FILE *inputFile) {    yajl_handle hand;    static unsigned char fileData[READ_BUFFER_SIZE];    ParseContext g;    g.sample = sample;    yajl_status stat;    size_t rd;    /* allow comments */    yajl_parser_config cfg = { 1, 1 };    int retval = 1, done = 0;    /* ok.  open file.  let's read and parse */    hand = yajl_alloc(&callbacks, &cfg, NULL, (void *) &g);            while (!done) {        rd = fread((void *) fileData, 1, sizeof(fileData) - 1, inputFile);                if (rd == 0) {            if (!feof(inputFile)) {                fprintf(stderr, "error on file read./n");                retval = 0;                break;            }            done = 1;        }        fileData[rd] = 0;                if (done)            /* parse any remaining buffered data */            stat = yajl_parse_complete(hand);        else            /* read file data, pass to parser */            stat = yajl_parse(hand, fileData, rd);        if (stat != yajl_status_ok &&            stat != yajl_status_insufficient_data)        {            unsigned char * str = yajl_get_error(hand, 1, fileData, rd);            fprintf(stderr, "%s", (const char *) str);            yajl_free_error(hand, str);            retval = 0;            if( stat == yajl_status_client_canceled) {                fprintf(stderr, "%s/n", g.lastError);            }            break;        }    }    yajl_free(hand);        return retval;}
开发者ID:cosbynator,项目名称:ABM-U-and-ABM-B-CPP,代码行数:53,


示例23: json_input

// Client records will be coming through in alphabetical order.// FIX THIS: If a client is deleted on the server, it is not deleted from// clist.int json_input(struct asfd *asfd, struct sel *sel){        static yajl_handle yajl=NULL;	cslist=&sel->clist;	sselbu=&sel->backup;	sllines=&sel->llines;	if(!yajl)	{		if(!(yajl=yajl_alloc(&callbacks, NULL, NULL)))			goto error;		yajl_config(yajl, yajl_dont_validate_strings, 1);	}	if(yajl_parse(yajl, (const unsigned char *)asfd->rbuf->buf,		asfd->rbuf->len)!=yajl_status_ok)	{		do_yajl_error(yajl, asfd);		goto error;	}	if(!map_depth)	{		// Got to the end of the JSON object.		if(!sel->gotfirstresponse) sel->gotfirstresponse=1;		if(yajl_complete_parse(yajl)!=yajl_status_ok)		{			do_yajl_error(yajl, asfd);			goto error;		}		yajl_free(yajl);		yajl=NULL;	}	return 0;error:	yajl_free(yajl);	yajl=NULL;	return -1;}
开发者ID:Shloub,项目名称:burp,代码行数:42,


示例24: SLNJSONFilterParserFree

void SLNJSONFilterParserFree(SLNJSONFilterParserRef *const parserptr) {	SLNJSONFilterParserRef parser = *parserptr;	if(!parser) return;	parser->session = NULL;	if(parser->JSONParser) {		yajl_free(parser->JSONParser); parser->JSONParser = NULL;	}	for(size_t i = 0; i < DEPTH_MAX; ++i) {		SLNFilterFree(&parser->stack[i]);	}	assert_zeroed(parser, 1);	FREE(parserptr); parser = NULL;}
开发者ID:andreydelpozo2,项目名称:stronglink,代码行数:13,


示例25: TEST_F

TEST_F(Yajl, yajl_parse_nullcallbacks) {	for (size_t i = 0; i < kTrialCount; i++) {		yajl_handle hand = yajl_alloc(&nullcallbacks, NULL, NULL);		yajl_status stat = yajl_parse(hand, (unsigned char*)json_, length_ - 1);		//ASSERT_EQ(yajl_status_ok, stat);		if (stat != yajl_status_ok) {			unsigned char * str = yajl_get_error(hand, 1, (unsigned char*)json_, length_ + 1);			fprintf(stderr, "%s", (const char *) str);		}		stat = yajl_complete_parse(hand);		ASSERT_EQ(yajl_status_ok, stat);		yajl_free(hand);	}	}
开发者ID:AlexTaylor1,项目名称:UltimatePinBall,代码行数:14,


示例26: reformat

void reformat(ErlDrvPort port, char* buf, int len){    yajl_handle hand;    /* generator config */    yajl_gen_config conf = { 1, "  " };	yajl_gen g;    yajl_status stat;    /* allow comments */    yajl_parser_config cfg = { 1, 1 };    g = yajl_gen_alloc(&conf, NULL);    /* ok.  open file.  let's read and parse */    hand = yajl_alloc(&callbacks, &cfg, NULL, (void *) g);        /* read file data, pass to parser */    stat = yajl_parse(hand, (unsigned char*) buf, len);    if (stat != yajl_status_ok &&        stat != yajl_status_insufficient_data)    {        char* err = (char*) yajl_get_error(hand, 1, (unsigned char*) buf, len);        int len = strlen(err);        ErlDrvTermData msg[] = {            ERL_DRV_ATOM, driver_mk_atom("error"),             ERL_DRV_BUF2BINARY, (ErlDrvTermData) err, (ErlDrvUInt) len,            ERL_DRV_TUPLE, 2        };        driver_send_term(port, driver_caller(port), msg, sizeof(msg) / sizeof(msg[0]));    } else {        const unsigned char* json;        unsigned int len;        yajl_gen_get_buf(g, &json, &len);        ErlDrvTermData msg[] = {            ERL_DRV_ATOM, driver_mk_atom("ok"),            ERL_DRV_BUF2BINARY, (ErlDrvTermData) json, (ErlDrvUInt) len,            ERL_DRV_TUPLE, 2        };        driver_send_term(port, driver_caller(port), msg, sizeof(msg) / sizeof(msg[0]));        yajl_gen_clear(g);    }    yajl_gen_free(g);    yajl_free(hand);}
开发者ID:dizzyd,项目名称:eep0018,代码行数:50,


示例27: main

int main(int argc, char ** argv){    yajl_handle hand;    yajl_status stat;    yajl_parser_config cfg = { 1, 1 };    int done = 0;    hand = yajl_alloc(&callbacks, &cfg, NULL, (void *) g);            while (!done) {        rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin);                if (rd == 0) {            if (!feof(stdin)) {                fprintf(stderr, "error on file read./n");                break;            }            done = 1;        }        fileData[rd] = 0;                if (done)            /* parse any remaining buffered data */            stat = yajl_parse_complete(hand);        else            /* read file data, pass to parser */            stat = yajl_parse(hand, fileData, rd);        if (stat != yajl_status_ok &&            stat != yajl_status_insufficient_data)        {            unsigned char * str = yajl_get_error(hand, 1, fileData, rd);            fprintf(stderr, (const char *) str);            yajl_free_error(hand, str);        } else {            const unsigned char * buf;            unsigned int len;            yajl_gen_get_buf(g, &buf, &len);            fwrite(buf, 1, len, stdout);            yajl_gen_clear(g);        }    }    yajl_gen_free(g);    yajl_free(hand);        return 0;}
开发者ID:bryanyuan2,项目名称:citc,代码行数:49,


示例28: jsonfill

void jsonfill(const char *filename,int *array){   std::ifstream fin(filename);   fin.seekg(0,std::ios::end);   int length = fin.tellg();   fin.seekg(0,std::ios::beg);   unsigned char *buffer = new unsigned char  [length];   fin.read ((char *) buffer,length);   fin.close();   yajl_handle handl = yajl_alloc(&call,&conf,NULL,&array);   yajl_parse(handl,buffer,length);   yajl_free(handl);   free(buffer);}
开发者ID:Lalaland,项目名称:Asteroids,代码行数:16,



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


C++ yajl_gen_string函数代码示例
C++ yajl_alloc函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。