示例#1
0
static void tsi_peer_destroy_list_property(tsi_peer_property *children,
                                           size_t child_count) {
  size_t i;
  for (i = 0; i < child_count; i++) {
    tsi_peer_property_destruct(&children[i]);
  }
  free(children);
}
示例#2
0
tsi_result tsi_construct_allocated_string_peer_property(
    const char *name, size_t value_length, tsi_peer_property *property) {
  *property = tsi_init_peer_property();
  if (name != NULL) {
    property->name = tsi_strdup(name);
    if (property->name == NULL) return TSI_OUT_OF_RESOURCES;
  }
  if (value_length > 0) {
    property->value.data = calloc(1, value_length);
    if (property->value.data == NULL) {
      tsi_peer_property_destruct(property);
      return TSI_OUT_OF_RESOURCES;
    }
    property->value.length = value_length;
  }
  return TSI_OK;
}
示例#3
0
tsi_result tsi_construct_list_peer_property(const char* name,
                                            size_t child_count,
                                            tsi_peer_property* property) {
  *property = tsi_init_peer_property();
  property->type = TSI_PEER_PROPERTY_TYPE_LIST;
  if (name != NULL) {
    property->name = tsi_strdup(name);
    if (property->name == NULL) return TSI_OUT_OF_RESOURCES;
  }
  if (child_count > 0) {
    property->value.list.children =
        calloc(child_count, sizeof(tsi_peer_property));
    if (property->value.list.children == NULL) {
      tsi_peer_property_destruct(property);
      return TSI_OUT_OF_RESOURCES;
    }
    property->value.list.child_count = child_count;
  }
  return TSI_OK;
}