static GDataFreebaseTopicValue * reader_create_value (JsonReader *reader, const gchar *property, TopicValueType type, GError **error) { GDataFreebaseTopicValue *value; value = g_slice_new0 (GDataFreebaseTopicValue); value->ref_count = 1; value->property = g_strdup (property); value->text = reader_dup_member_string (reader, "text", error); value->lang = reader_dup_member_string (reader, "lang", error); /* Not all parsed nodes are meant to contain creator/timestamp tags, * do not pass error to those, so parsing continues. */ value->creator = reader_dup_member_string (reader, "creator", NULL); value->timestamp = reader_parse_timestamp (reader, "timestamp", NULL); if (reader_fill_simple_gvalue (reader, type, &value->value) || reader_fill_object_gvalue (reader, type, &value->value) || reader_fill_compound_gvalue (reader, type, &value->value, error)) return value; value_free (value); return NULL; }
/* Called by the Python interpreter when deallocating a value object. */ static void valpy_dealloc (PyObject *obj) { value_object *self = (value_object *) obj; /* Remove SELF from the global list. */ if (self->prev) self->prev->next = self->next; else { gdb_assert (values_in_python == self); values_in_python = self->next; } if (self->next) self->next->prev = self->prev; value_free (self->value); if (self->address) /* Use braces to appease gcc warning. *sigh* */ { Py_DECREF (self->address); } if (self->type) { Py_DECREF (self->type); } Py_XDECREF (self->dynamic_type); Py_TYPE (self)->tp_free (self); }
static gboolean val_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc) { fvalue_t *fv_bytes; tvbuff_t *new_tvb; guint8 *private_data; /* Free up the old value, if we have one */ value_free(fv); /* Does this look like a byte string? */ fv_bytes = fvalue_from_unparsed(FT_BYTES, s, TRUE, NULL); if (fv_bytes) { /* Make a tvbuff from the bytes */ private_data = (guint8 *)g_memdup(fv_bytes->value.bytes->data, fv_bytes->value.bytes->len); new_tvb = tvb_new_real_data(private_data, fv_bytes->value.bytes->len, fv_bytes->value.bytes->len); /* Let the tvbuff know how to delete the data. */ tvb_set_free_cb(new_tvb, free_tvb_data); /* And let us know that we need to free the tvbuff */ fv->tvb_is_private = TRUE; fv->value.tvb = new_tvb; return TRUE; } /* Treat it as a string. */ return val_from_string(fv, s, logfunc); }
gboolean rra_di_value_action_free(rra_di_value_action *in_action) { ustr_free(in_action->path); ustr_free(in_action->name); if (in_action->val_old != NULL) { value_free(in_action->val_old); } if (in_action->val_new != NULL) { value_free(in_action->val_new); } rra_free_type(rra_di_value_action, in_action); return TRUE; }
void pair_free (struct pair *p) { str_free (p->key); free (p->key); value_free (p->value); free (p); }
/** * gdata_freebase_topic_value_unref: * @value: (transfer full): a #GDataFreebaseTopicValue * * Removes a reference from @value. If the reference count drops to 0, * the object is freed. * * Since: 0.15.1 **/ void gdata_freebase_topic_value_unref (GDataFreebaseTopicValue *value) { g_return_if_fail (value != NULL); if (g_atomic_int_dec_and_test (&value->ref_count)) value_free (value); }
static void value_set(fvalue_t *fv, tvbuff_t *value) { /* Free up the old value, if we have one */ value_free(fv); fv->value.tvb = value; }
static void exec(const Ast *ast) { //printf("executing "); pn(ast); Value *v; switch(ast->class) { case N_BLOCK: block(ast); return; case N_IF: ifstat(ast); return; case N_WHILE: whilestat(ast); return; case N_DECLARATION: declaration(ast); return; case N_FUNCTION: return; case N_RETURN: returnstat(ast); return; case N_CALL: case N_ASSIGNMENT: case N_IDENTIFIER: case N_NEG: case N_NOT: case N_EQ: case N_NEQ: case N_AND: case N_IOR: case N_XOR: case N_LT: case N_LE: case N_GE: case N_GT: case N_ADD: case N_SUB: case N_MUL: case N_DIV: case N_POW: case N_MOD: case N_BOOLEAN: case N_INTEGER: case N_FLOAT: case N_STRING: case N_SET: case N_R: v = eval(ast); //do { print_tree(2, ast); dprintf(2, " evaluates to "); pv(v); } while(0); value_free(v); return; } printf("EXECFAIL %d ", ast->class); pn(ast); assert(false && "should not be reached"); }
/* * Free the memory space occupied by Matrix 'Mat' */ void Matrix_Free(Matrix *Mat) { if (Mat->p_Init) value_free(Mat->p_Init, Mat->p_Init_size); if (Mat->p) free(Mat->p); free(Mat); } /* Matrix_Free */
static void value_set(fvalue_t *fv, gpointer value, gboolean already_copied) { g_assert(already_copied); /* Free up the old value, if we have one */ value_free(fv); fv->value.tvb = (tvbuff_t *)value; }
void value_list_free (struct value_lst *lst) { while (lst) { struct value_lst *next = lst->next; value_free (lst->value); free (lst); lst = next; } }
void gen_record_free (struct gen_record *r) { if (r->singleton) value_free (r->cont.value); else pair_list_free (r->cont.list); str_free (r->id); free (r->id); free (r); }
static void free_table (VirtualBBoxPtr p_vt) { /* memory cleanup; freeing the virtual table struct */ int i; if (!p_vt) return; if (p_vt->table) sqlite3_free (p_vt->table); if (p_vt->Column) { for (i = 0; i < p_vt->nColumns; i++) { if (*(p_vt->Column + i)) sqlite3_free (*(p_vt->Column + i)); } sqlite3_free (p_vt->Column); } if (p_vt->Type) { for (i = 0; i < p_vt->nColumns; i++) { if (*(p_vt->Type + i)) sqlite3_free (*(p_vt->Type + i)); } sqlite3_free (p_vt->Type); } if (p_vt->Visible) sqlite3_free (p_vt->Visible); if (p_vt->Value) { for (i = 0; i < p_vt->nColumns; i++) { if (*(p_vt->Value + i)) value_free (*(p_vt->Value + i)); } sqlite3_free (p_vt->Value); } if (p_vt->MinX) sqlite3_free (p_vt->MinX); if (p_vt->MinY) sqlite3_free (p_vt->MinY); if (p_vt->MaxX) sqlite3_free (p_vt->MaxX); if (p_vt->MaxY) sqlite3_free (p_vt->MaxY); if (p_vt->ColSrid) sqlite3_free (p_vt->ColSrid); if (p_vt->BBoxGeom) gaiaFreeGeomColl (p_vt->BBoxGeom); sqlite3_free (p_vt); }
value value_tail_now(value *op) { if (op->type == VALUE_NIL) { value_error(1, "Error: cannot find tail!() of an empty list."); return value_init_error(); } else if (op->type == VALUE_ARY) { size_t i, length = value_length(*op); if (length == 0) { value_error(1, "Error: cannot find tail!() of an empty array."); return value_init_error(); } value_clear(&op->core.u_a.a[0]); for (i = 0; i < length-1; ++i) op->core.u_a.a[i] = op->core.u_a.a[i+1]; --op->core.u_a.length; } else if (op->type == VALUE_LST) { if (value_empty_p(*op)) { value_error(1, "Error: cannot find tail!() of an empty list."); return value_init_error(); } else { value_clear(&op->core.u_l[0]); value_free(op->core.u_l); *op = op->core.u_l[1]; } } else if (op->type == VALUE_PAR) { value tmp = op->core.u_p->tail; value_clear(&op->core.u_p->head); value_free(op->core.u_p); *op = tmp; } else { value_error(1, "Type Error: tail!() is undefined where op is %ts (array or list expected).", *op); return value_init_error(); } return value_init_nil(); }
static void ifstat(const Ast *if_stmt) { Ast *cond_expr = if_stmt->child; Ast *then_stmt = if_stmt->child->next; Ast *else_stmt = if_stmt->child->next->next; Value *cond; if((cond = eval(cond_expr))->as_bool) { exec(then_stmt); } else if(else_stmt != NULL) { exec(else_stmt); } value_free(cond); }
static Value * _and(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); if(v1->as_bool == false) { return v1; } value_free(v1); return eval(op2); }
static Value * _gt(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); Value *v2 = eval(op2); Value *rval = v1; value_set_bool(rval, NATIVE_NUMBER(v1) > NATIVE_NUMBER(v2)); value_free(v2); return rval; }
static Value * _ior(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); if((v1->as_bool) == true) { return v1; } value_free(v1); return eval(op2); }
static void read_names_and_ids(SamInfo *in_info) { int i; KeyCell *names_kc = registry_path_get_key(in_info->reg, USER_NAME_PATH); in_info->names = ustrlist_new(); in_info->ids = g_array_new(TRUE, TRUE, sizeof(gint32)); for (i = 0; i < key_cell_get_number_of_subkeys(names_kc); i++) { KeyCell *subk = key_cell_get_subkey(names_kc, i); ustrlist_append(in_info->names, key_cell_get_name(subk)); ValueKeyCell *vkey = key_cell_get_value_str(subk, ""); Value *val = value_key_cell_get_val(vkey); dword_type id = value_get_as_dword(val); g_array_append_val(in_info->ids, id); value_free(val); } }
SLPError generic_set_val(struct xx_SLPAttributes *slp_attr, const char *tag, value_t *value, SLPInsertionPolicy policy, SLPType attr_type) /* Finds and sets the value named in tag. */ /* * slp_attr - The attr object to add to. * tag - the name of the tag to add to. * value - the already-allocated value object with fields set * policy - the policy to use when inserting. * attr_type - the type of the value being added. *****************************************************************************/ { var_t *var; /***** Create a new attribute. *****/ if ( (var = attr_val_find_str(slp_attr, tag)) == NULL) { /*** Couldn't find a value with this tag. Make a new one. ***/ var = var_new((char *)tag); if (var == NULL) { return SLP_MEMORY_ALLOC_FAILED; } var->type = attr_type; /** Add variable to list. **/ attr_add(slp_attr, var); } else { SLPError err; /*** The attribute already exists. ***/ /*** Verify type. ***/ err = attr_type_verify(slp_attr, var, attr_type); if (err == SLP_TYPE_ERROR && policy == SLP_REPLACE) { var_list_destroy(var); var->type = attr_type; } else if (err != SLP_OK) { value_free(value); return err; } } /***** Set value *****/ var_insert(var, value, policy); return SLP_OK; }
static Value * _mod(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); Value *v2 = eval(op2); Value *rval = v1; switch(expr->eval_type) { case T_INT: value_set_int(rval, v1->as_int % v2->as_int); break; default: pty(expr->eval_type); assert(false); } value_free(v2); return rval; }
/* Called by the Python interpreter when deallocating a value object. */ static void valpy_dealloc (PyObject *obj) { value_object *self = (value_object *) obj; value_remove_from_list (&values_in_python, self->value); value_free (self->value); if (self->address) /* Use braces to appease gcc warning. *sigh* */ { Py_DECREF (self->address); } if (self->type) { Py_DECREF (self->type); } self->ob_type->tp_free (self); }
static Value * _eq(const Ast *expr) { Ast *op1 = expr->child; Ast *op2 = expr->child->next; Value *v1 = eval(op1); Value *v2 = eval(op2); Value *rval = v1; if(v1->type != v2->type) { value_set_bool(rval, false); } else { switch(v1->type) { case T_BOOL: value_set_bool(rval, v1->as_bool == v2->as_bool); break; case T_INT: value_set_bool(rval, v1->as_int == v2->as_int); break; case T_FLOAT: value_set_bool(rval, fabs((v1->as_float - v2->as_float)) < 0.05); break; case T_STRING: value_set_bool(rval, strcmp(v1->as_String, v2->as_String) == 0); break; case T_SET: value_set_bool(rval, rf_set_equal(v1->as_Set, v2->as_Set)); break; case T_R: value_set_bool(rval, rf_relation_equal(v1->as_Relation, v2->as_Relation)); break; } } value_free(v2); return rval; }
static gboolean val_from_string(fvalue_t *fv, char *s, LogFunc logfunc _U_) { tvbuff_t *new_tvb; guint8 *private_data; /* Free up the old value, if we have one */ value_free(fv); /* Make a tvbuff from the string. We can drop the * terminating NUL. */ private_data = (guint8 *)g_memdup(s, (guint)strlen(s)); new_tvb = tvb_new_real_data(private_data, (guint)strlen(s), (gint)strlen(s)); /* Let the tvbuff know how to delete the data. */ tvb_set_free_cb(new_tvb, free_tvb_data); /* And let us know that we need to free the tvbuff */ fv->tvb_is_private = TRUE; fv->value.tvb = new_tvb; return TRUE; }
int c_direct_get(const struct buxton_layer *layer, const char *key, UNUSED const char *value, UNUSED const char *rpriv, UNUSED const char *wpriv) { int r; struct buxton_value val; if (!layer || !key || !*key) { errno = EINVAL; bxt_err("Get: Layer '%s' Key '%s': %s", layer ? buxton_layer_get_name(layer) : "", key ? key : "", strerror(errno)); return -1; } r = c_init(); if (r == -1) return -1; r = direct_get(layer, key, &val); c_exit(); if (r == -1) { bxt_err("Get: Layer '%s' Key '%s': %s", buxton_layer_get_name(layer), key, strerror(errno)); return -1; } c_print_value(layer, key, &val); value_free(&val); return 0; }
static void value_free_ignoring_symbols(Value *value) { if (value->type != TYPE_SYMBOL) { value_free(value); } }