Commit 2e4c2694 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Constify. Plug leak.

2000-09-11  Morten Welinder  <terra@diku.dk>

	* color-group.c (color_group_new_named): Constify.  Plug leak.

	* color-palette.c (color_palette_new_with_vals): Constify.
	(color_palette_new): Constify.
parent 8d0bbe6b
......@@ -1598,24 +1598,6 @@ gnumeric_rate (FunctionEvalInfo *ei, Value **argv)
if (udata.type != 0 && udata.type != 1)
return value_new_error (ei->pos, gnumeric_err_VALUE);
#if 0
/*
* Mark Copper <ad8854@wayne.edu> submits that the following
* special case is not worth the effort and risk of being
* incorrect since the goal seek below will converge really
* fast in this case.
*/
if (udata.pmt == 0) {
if (udata.pv == 0 || udata.pv * udata.fv > 0)
return value_new_error (ei->pos, gnumeric_err_NUM);
else {
/* Exact case. */
return value_new_float (pow (-udata.fv / udata.pv,
1.0 / udata.nper) - 1);
}
}
#endif
#if 0
printf ("Guess = %.15g\n", rate0);
#endif
......@@ -1639,7 +1621,7 @@ gnumeric_rate (FunctionEvalInfo *ei, Value **argv)
if (status != GOAL_SEEK_OK) {
int factor;
/* Lay a net of test points around the guess. */
for (factor = 2; factor < 100; factor *= 2) {
for (factor = 2; !(data.havexneg && data.havexpos) && factor < 100; factor *= 2) {
goal_seek_point (&gnumeric_rate_f, &data, &udata, rate0 * factor);
goal_seek_point (&gnumeric_rate_f, &data, &udata, rate0 / factor);
}
......@@ -1768,7 +1750,7 @@ gnumeric_irr (FunctionEvalInfo *ei, Value **argv)
if (status != GOAL_SEEK_OK) {
int factor;
/* Lay a net of test points around the guess. */
for (factor = 2; factor < 100; factor *= 2) {
for (factor = 2; !(data.havexneg && data.havexpos) && factor < 100; factor *= 2) {
goal_seek_point (&irr_npv, &data, &p, rate0 * factor);
goal_seek_point (&irr_npv, &data, &p, rate0 / factor);
}
......
/*
* color-group.c : Utility to keep a ahered memory of custom and
* color-group.c : Utility to keep a shered memory of custom and
* current colors between arbitrary widgets
*
* Author:
......@@ -223,7 +223,7 @@ color_group_set_history_size (ColorGroup *cg, gint size)
* incremented and a pointer to the group is returned.
*/
GtkObject *
color_group_new_named (gchar * name)
color_group_new_named (const gchar *name)
{
GtkObject *obj;
ColorGroup *cg;
......@@ -237,7 +237,9 @@ color_group_new_named (gchar * name)
else
new_name = g_strdup (name);
if((obj = color_group_from_name(new_name)) != NULL) {
obj = color_group_from_name (new_name);
if (obj) {
g_free (new_name);
gtk_object_ref(GTK_OBJECT(obj));
return obj;
}
......
......@@ -19,7 +19,7 @@ typedef struct _ColorGroup ColorGroup;
GtkType color_group_get_type (void);
GtkObject *color_group_new_named (gchar * name);
GtkObject *color_group_new_named (const gchar *name);
void color_group_set_history_size (ColorGroup *cg, gint size);
......
......@@ -36,7 +36,7 @@ struct _ColorPalette {
* Array of colors
*/
GnomeCanvasItem **items;
/* The (potententially NULL) default color */
/* The (potentially NULL) default color */
GdkColor *default_color;
/*
* Position of the last possible position
......@@ -510,7 +510,7 @@ static GtkWidget*
color_palette_new_with_vals ( char const * const no_color_label,
int ncols, int nrows, ColorNamePair *color_names,
GdkColor *default_color,
gchar *group_name){
const gchar *group_name){
ColorPalette *P;
g_return_val_if_fail (color_names != NULL, NULL);
......@@ -614,7 +614,8 @@ static ColorNamePair default_color_set [] = {
*/
GtkWidget*
color_palette_new ( char const * const no_color_label,
GdkColor *default_color, gchar *group_name) {
GdkColor *default_color, const gchar *group_name)
{
/* specify 6 rows to allow for a row of custom colors */
return color_palette_new_with_vals (no_color_label,
8, 6,
......
......@@ -17,7 +17,7 @@ GtkType color_palette_get_type (void);
GtkWidget *color_palette_new (char const * const no_color_label,
GdkColor *default_color,
gchar *group_name);
const gchar *group_name);
GdkColor *color_palette_get_current_color (ColorPalette *P);
GtkWidget *color_palette_get_color_picker (ColorPalette *P);
......
......@@ -1598,24 +1598,6 @@ gnumeric_rate (FunctionEvalInfo *ei, Value **argv)
if (udata.type != 0 && udata.type != 1)
return value_new_error (ei->pos, gnumeric_err_VALUE);
#if 0
/*
* Mark Copper <ad8854@wayne.edu> submits that the following
* special case is not worth the effort and risk of being
* incorrect since the goal seek below will converge really
* fast in this case.
*/
if (udata.pmt == 0) {
if (udata.pv == 0 || udata.pv * udata.fv > 0)
return value_new_error (ei->pos, gnumeric_err_NUM);
else {
/* Exact case. */
return value_new_float (pow (-udata.fv / udata.pv,
1.0 / udata.nper) - 1);
}
}
#endif
#if 0
printf ("Guess = %.15g\n", rate0);
#endif
......@@ -1639,7 +1621,7 @@ gnumeric_rate (FunctionEvalInfo *ei, Value **argv)
if (status != GOAL_SEEK_OK) {
int factor;
/* Lay a net of test points around the guess. */
for (factor = 2; factor < 100; factor *= 2) {
for (factor = 2; !(data.havexneg && data.havexpos) && factor < 100; factor *= 2) {
goal_seek_point (&gnumeric_rate_f, &data, &udata, rate0 * factor);
goal_seek_point (&gnumeric_rate_f, &data, &udata, rate0 / factor);
}
......@@ -1768,7 +1750,7 @@ gnumeric_irr (FunctionEvalInfo *ei, Value **argv)
if (status != GOAL_SEEK_OK) {
int factor;
/* Lay a net of test points around the guess. */
for (factor = 2; factor < 100; factor *= 2) {
for (factor = 2; !(data.havexneg && data.havexpos) && factor < 100; factor *= 2) {
goal_seek_point (&irr_npv, &data, &p, rate0 * factor);
goal_seek_point (&irr_npv, &data, &p, rate0 / factor);
}
......
2000-09-11 Morten Welinder <terra@diku.dk>
* color-group.c (color_group_new_named): Constify. Plug leak.
* color-palette.c (color_palette_new_with_vals): Constify.
(color_palette_new): Constify.
2000-09-10 Miguel de Icaza <miguel@helixcode.com>
* widget-editable-label.c (el_start_editing): Optionally select
......
/*
* color-group.c : Utility to keep a ahered memory of custom and
* color-group.c : Utility to keep a shered memory of custom and
* current colors between arbitrary widgets
*
* Author:
......@@ -223,7 +223,7 @@ color_group_set_history_size (ColorGroup *cg, gint size)
* incremented and a pointer to the group is returned.
*/
GtkObject *
color_group_new_named (gchar * name)
color_group_new_named (const gchar *name)
{
GtkObject *obj;
ColorGroup *cg;
......@@ -237,7 +237,9 @@ color_group_new_named (gchar * name)
else
new_name = g_strdup (name);
if((obj = color_group_from_name(new_name)) != NULL) {
obj = color_group_from_name (new_name);
if (obj) {
g_free (new_name);
gtk_object_ref(GTK_OBJECT(obj));
return obj;
}
......
......@@ -19,7 +19,7 @@ typedef struct _ColorGroup ColorGroup;
GtkType color_group_get_type (void);
GtkObject *color_group_new_named (gchar * name);
GtkObject *color_group_new_named (const gchar *name);
void color_group_set_history_size (ColorGroup *cg, gint size);
......
......@@ -36,7 +36,7 @@ struct _ColorPalette {
* Array of colors
*/
GnomeCanvasItem **items;
/* The (potententially NULL) default color */
/* The (potentially NULL) default color */
GdkColor *default_color;
/*
* Position of the last possible position
......@@ -510,7 +510,7 @@ static GtkWidget*
color_palette_new_with_vals ( char const * const no_color_label,
int ncols, int nrows, ColorNamePair *color_names,
GdkColor *default_color,
gchar *group_name){
const gchar *group_name){
ColorPalette *P;
g_return_val_if_fail (color_names != NULL, NULL);
......@@ -614,7 +614,8 @@ static ColorNamePair default_color_set [] = {
*/
GtkWidget*
color_palette_new ( char const * const no_color_label,
GdkColor *default_color, gchar *group_name) {
GdkColor *default_color, const gchar *group_name)
{
/* specify 6 rows to allow for a row of custom colors */
return color_palette_new_with_vals (no_color_label,
8, 6,
......
......@@ -17,7 +17,7 @@ GtkType color_palette_get_type (void);
GtkWidget *color_palette_new (char const * const no_color_label,
GdkColor *default_color,
gchar *group_name);
const gchar *group_name);
GdkColor *color_palette_get_current_color (ColorPalette *P);
GtkWidget *color_palette_get_color_picker (ColorPalette *P);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment