Example #1
0
static size_t run(int i)
{
  upb_status status = UPB_STATUS_INIT;
  i %= NUM_MESSAGES;
  upb_msg_clear(msg[i], def);
  upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc),
                    0, UPB_NONDELIMITED, msg[i]);
  upb_decoder_decode(&d, &status);
  if(!upb_ok(&status)) goto err;
  return len;

err:
  fprintf(stderr, "Decode error: %s", upb_status_getstr(&status));
  return 0;
}
static size_t run(int i)
{
  (void)i;
  upb_status status = UPB_STATUS_INIT;
  upb_msg_clear(msg, def);
  upb_stringsrc_reset(&strsrc, input_str);
  upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc), msg);
  upb_decoder_decode(&d, &status);
  if(!upb_ok(&status)) goto err;
  return upb_string_len(input_str);

err:
  fprintf(stderr, "Decode error: ");
  upb_printerr(&status);
  return 0;
}
Example #3
0
void upb_stdmsg_recycle(void **m, const upb_msgdef *md) {
  if (*m)
    upb_msg_clear(*m, md);
  else
    *m = upb_stdmsg_new(md);
}
Example #4
0
void *upb_stdmsg_new(const upb_msgdef *md) {
  void *m = malloc(md->size);
  memset(m, 0, md->size);
  upb_msg_clear(m, md);
  return m;
}