Exemple #1
0
void upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len) {
  assert(upb_isstring(f) || f->type == UPB_TYPE(ENUM));
  upb_byteregion *bytes = upb_value_getbyteregion(f->defaultval);
  assert(bytes);
  upb_byteregion_free(bytes);
  upb_value_setbyteregion(&f->defaultval, upb_byteregion_newl(str, len));
  f->default_is_symbolic = true;
}
Exemple #2
0
void upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len) {
  assert(upb_isstring(f) || f->type == UPB_TYPE(ENUM));
  const upb_strref *ref = upb_value_getstrref(f->defaultval);
  assert(ref);
  upb_strref_free((upb_strref*)ref);
  upb_value_setstrref(&f->defaultval, upb_strref_newl(str, len));
  f->default_is_symbolic = true;
}
Exemple #3
0
void upb_stdseq_free(void *s, upb_fielddef *f) {
  upb_stdarray *a = s;
  if (upb_issubmsg(f) || upb_isstring(f)) {
    void **p = (void**)a->ptr;
    for (uint32_t i = 0; i < a->size; i++) {
      if (upb_issubmsg(f)) {
        upb_stdmsg_free(p[i], upb_downcast_msgdef(f->def));
      } else {
        upb_stdarray *str = p[i];
        free(str->ptr);
        free(str);
      }
    }
  }
  free(a->ptr);
  free(a);
}
Exemple #4
0
void upb_stdmsg_free(void *m, const upb_msgdef *md) {
  if (m == NULL) return;
  upb_msg_iter i;
  for(i = upb_msg_begin(md); !upb_msg_done(i); i = upb_msg_next(md, i)) {
    upb_fielddef *f = upb_msg_iter_field(i);
    if (!upb_isseq(f) && !upb_issubmsg(f) && !upb_isstring(f)) continue;
    void *subp = upb_value_getptr(upb_stdmsg_getptr(m, f->fval));
    if (subp == NULL) continue;
    if (upb_isseq(f)) {
      upb_stdseq_free(subp, f);
    } else if (upb_issubmsg(f)) {
      upb_stdmsg_free(subp, upb_downcast_msgdef(f->def));
    } else {
      upb_stdarray *str = subp;
      free(str->ptr);
      free(str);
    }
  }
  free(m);
}
Exemple #5
0
void upb_fielddef_setdefault(upb_fielddef *f, upb_value value) {
  assert(!f->finalized);
  assert(!upb_isstring(f));
  f->defaultval = value;
}
Exemple #6
0
static void upb_fielddef_uninit_default(upb_fielddef *f) {
  if (upb_isstring(f) || f->default_is_symbolic) {
    upb_byteregion_free(upb_value_getbyteregion(f->defaultval));
  }
}
Exemple #7
0
static void upb_fielddef_uninit_default(upb_fielddef *f) {
  if (upb_isstring(f) || f->default_is_symbolic) {
    upb_strref_free((upb_strref*)upb_value_getstrref(f->defaultval));
  }
}