summaryrefslogtreecommitdiff
path: root/src/math-buttons.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-03-05 13:06:45 +0100
committerraveit65 <[email protected]>2020-03-08 21:40:41 +0100
commitb0117b1d5ae73916c6f0d289be1f693bb5f46824 (patch)
tree4751c73751ed9951ae5a1c5b93f04c84593c6974 /src/math-buttons.c
parent91962719d06ce16d8bc3523872b83fae4d151e10 (diff)
downloadmate-calc-b0117b1d5ae73916c6f0d289be1f693bb5f46824.tar.bz2
mate-calc-b0117b1d5ae73916c6f0d289be1f693bb5f46824.tar.xz
Port to GNU MPFR/MPC Library
For further information please visit: https://www.mpfr.org/ http://www.multiprecision.org/mpc
Diffstat (limited to 'src/math-buttons.c')
-rw-r--r--src/math-buttons.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/math-buttons.c b/src/math-buttons.c
index 4e6e6da..69e993a 100644
--- a/src/math-buttons.c
+++ b/src/math-buttons.c
@@ -360,7 +360,7 @@ load_finc_dialogs(MathButtons *buttons)
static void
update_bit_panel(MathButtons *buttons)
{
- MPNumber x;
+ MPNumber x = mp_new();
gboolean enabled;
guint64 bits;
int i;
@@ -373,14 +373,17 @@ update_bit_panel(MathButtons *buttons)
enabled = math_equation_get_number(buttons->priv->equation, &x);
if (enabled) {
- MPNumber max, fraction;
+ MPNumber max = mp_new();
+ MPNumber fraction = mp_new();
mp_set_from_unsigned_integer(G_MAXUINT64, &max);
mp_fractional_part(&x, &fraction);
if (mp_is_negative(&x) || mp_is_greater_than(&x, &max) || !mp_is_zero(&fraction))
enabled = FALSE;
else
- bits = mp_cast_to_unsigned_int(&x);
+ bits = mp_to_unsigned_integer(&x);
+ mp_clear(&max);
+ mp_clear(&fraction);
}
gtk_widget_set_sensitive(buttons->priv->bit_panel, enabled);
@@ -422,6 +425,7 @@ update_bit_panel(MathButtons *buttons)
gtk_label_set_text(GTK_LABEL(buttons->priv->base_label), label->str);
g_string_free(label, TRUE);
+ mp_clear(&x);
}
@@ -1177,6 +1181,7 @@ finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons)
dialog = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "finc_dialog"));
for (i = 0; i < 4; i++) {
+ arg[i] = mp_new();
if (finc_dialog_fields[dialog][i] == NULL) {
continue;
}
@@ -1187,6 +1192,10 @@ finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons)
gtk_widget_grab_focus(GET_WIDGET(buttons->priv->financial_ui, finc_dialog_fields[dialog][0]));
do_finc_expression(buttons->priv->equation, dialog, &arg[0], &arg[1], &arg[2], &arg[3]);
+
+ for (i = 0; i < 4; i++) {
+ mp_clear(&arg[i]);
+ }
}
@@ -1200,7 +1209,7 @@ character_code_dialog_response_cb(GtkWidget *dialog, gint response_id, MathButto
text = gtk_entry_get_text(GTK_ENTRY(buttons->priv->character_code_entry));
if (response_id == GTK_RESPONSE_OK) {
- MPNumber x;
+ MPNumber x = mp_new();
int i = 0;
mp_set_from_integer(0, &x);
@@ -1213,10 +1222,9 @@ character_code_dialog_response_cb(GtkWidget *dialog, gint response_id, MathButto
else
break;
}
-
math_equation_insert_number(buttons->priv->equation, &x);
+ mp_clear(&x);
}
-
gtk_widget_hide(dialog);
}