Example #1
0
int config_setting_remove(config_setting_t *parent, const char *name)
{
  unsigned int idx;
  config_setting_t *setting;

  if(! parent)
    return(CONFIG_FALSE);

  if(parent->type != CONFIG_TYPE_GROUP)
    return(CONFIG_FALSE);

  if(! (setting = __config_list_search(parent->value.list, name, &idx)))
    return(CONFIG_FALSE);

  __config_list_remove(parent->value.list, idx);
  __config_setting_destroy(setting);

  return(CONFIG_TRUE);
}
Example #2
0
int config_setting_remove_elem (config_setting_t * parent, unsigned int idx)
{
    config_list_t *list;
    config_setting_t *removed = NULL;

    if (!parent)
        return (CONFIG_FALSE);

    list = parent->value.list;

    if (((parent->type != CONFIG_TYPE_ARRAY) && (parent->type != CONFIG_TYPE_LIST) && (parent->type != CONFIG_TYPE_GROUP)) || !list)
        return (CONFIG_FALSE);

    if (idx >= list->length)
        return (CONFIG_FALSE);

    removed = __config_list_remove (list, idx);
    __config_setting_destroy (removed);

    return (CONFIG_TRUE);
}