[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: x_color.nw
User: cnieves
Date: 05/12/17 08:59:14
Modified: . x_color.nw x_dialog.nw
Log:
Use dynamic memory allocation in x_color_get_name and changed its definition.
Revision Changes Path
1.8 +6 -10 eda/geda/devel/gschem/noweb/x_color.nw
(In the diff below, changes in quantity of whitespace are not shown.)
Index: x_color.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/x_color.nw,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- x_color.nw 23 Oct 2005 23:46:42 -0000 1.7
+++ x_color.nw 17 Dec 2005 13:59:13 -0000 1.8
@@ -221,28 +221,24 @@
@section Function @code{x_color_get_name()}
-@defun x_color_get_name index string
+@defun x_color_get_name index
@end defun
<<x_color.c : x_color_get_name()>>=
-int
-x_color_get_name(int index, char *string)
+gchar *
+x_color_get_name(int index)
{
if ((index >= MAX_COLORS) || (index < 0)) {
- return(FALSE);
+ return(NULL);
}
/* only if these two variables are not null is the color settable */
if (colors[index].color_name && colors[index].outline_color_name) {
- if (string) {
- strcpy(string, colors[index].color_name);
- }
- return(TRUE);
+ return (g_strdup(colors[index].color_name));
}
- string[0] = '\0';
/* didn't find a color, but there still might be more */
- return(-1);
+ return(NULL);
}
1.37 +16 -19 eda/geda/devel/gschem/noweb/x_dialog.nw
(In the diff below, changes in quantity of whitespace are not shown.)
Index: x_dialog.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/x_dialog.nw,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- x_dialog.nw 4 Oct 2005 18:59:10 -0000 1.36
+++ x_dialog.nw 17 Dec 2005 13:59:13 -0000 1.37
@@ -3461,10 +3461,9 @@
GtkWidget *menuitem;
GSList *group;
int index=0;
- char buf[30]; /* should be be big enough hack */
+ char *buf;
char *menu_string;
char *temp=NULL;
- int found=0;
/* first lets see if we have a selected object, if so select its color */
int select_col = -1;
@@ -3489,21 +3488,22 @@
}
}else /*fprintf(stderr, "no object selected\n")*/;
- found = x_color_get_name(index, buf);
- /* this looks weired, but besides TRUE(1) and FALSE(0) there's -1 */
- while (found != FALSE) {
-
- if (found == TRUE) {
+ for (index=0; index < MAX_COLORS;index++) {
+ if ((buf=x_color_get_name(index)) != NULL) {
temp = index2functionstring(index);
menu_string = g_strdup_printf("%d | %s | %s", index,
temp,
buf);
free(temp);
-
+ temp = NULL;
+ g_free(buf);
+ buf = NULL;
menuitem = gtk_radio_menu_item_new_with_label (group,
menu_string);
free(menu_string);
+ menu_string = NULL;
+
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(
menuitem));
@@ -3536,9 +3536,6 @@
gtk_widget_show(menuitem);
item_index++;
}
-
- index++;
- found = x_color_get_name(index, buf);
}