rem: free(win_title);
context: main(int argc, char *argv[]){    GtkWidget *main_win;    GtkWidget *vbox;    GtkWidget *hbox;    GtkWidget *menubar;    GtkStyle  *textStyle;    gint      screen_width, width, height;    int       read_opt;    int       i;    char      *win_title;    int       req_width = -1, req_height = -1, req_x = 0, req_y = 0;    char      *rest, *project_filename = NULL;    /*     * Setup the screen info. Must do this before getopt, since getopt     * eventually will set some variables in screen.     */    memset((void *)&screen, 0, sizeof(gerbv_screen_t));    screen.state = NORMAL;    screen.execpath = dirname(argv[0]);    setup_init();	#ifdef HAVE_GETOPT_LONG    while ((read_opt = getopt_long(argc, argv, "Vl:", 				   longopts, &longopt_idx)) != -1) {#else    while ((read_opt = getopt(argc, argv, "Vl:")) != -1) {#endif /* HAVE_GETOPT_LONG */	switch (read_opt) {#ifdef HAVE_GETOPT_LONG	case 0:	    /* Only long options like GDK/GTK debug */	    switch (longopt_val) {	    case 0: /* default value if nothing is set */		printf("Not handled option %s\n", longopts[longopt_idx].name);		break;	    case 1: /* geometry */		req_width = (int)strtol(optarg, &rest, 10);		if (rest[0] != 'x'){		    printf("Split X and Y parameters with an x\n");		    break;		}		rest++;		req_height = (int)strtol(rest, &rest, 10);		if ((rest[0] == 0) || ((rest[0] != '-') && (rest[0] != '+')))		    break;		req_x = (int)strtol(rest, &rest, 10);		if ((rest[0] == 0) || ((rest[0] != '-') && (rest[0] != '+')))		    break;		req_y = (int)strtol(rest, &rest, 10);		break;	    case 3: /* project */		project_filename = optarg;		break;	    default:		break;	    }	    break;#endif /* HAVE_GETOPT_LONG */	case 'V' :	    printf("gerbv version %s\n", VERSION);	    printf("(C) Stefan Petersen (spe@stacken.kth.se)\n");	    exit(0);	case 'l' :	    if (optarg == NULL) {		fprintf(stderr, "You must give a filename to send log to\n");		exit(1);	    }	    setup.log.to_file = 1;	    setup.log.filename = optarg;	    break;	case '?':	    fprintf(stderr, "Usage : %s [FLAGS] <gerber file(s)>\n", argv[0]);	    fprintf(stderr, "where FLAGS could be any of\n");	    fprintf(stderr, "  --version|-V : Prints version of gerbv\n");	    fprintf(stderr, "  --log=<logfile>|-l <logfile> : Send error messages to <logfile>\n");	    exit(1);	    break;	default :	    printf("Not handled option [%d=%c]\n", read_opt, read_opt);	}    }        /*     * Init GTK+     */    gtk_init(&argc, &argv);    /*      * Good defaults according to Ales. Gives aspect ratio of 1.3333...     */    if ((req_width != -1) && (req_height != -1)) {	width = req_width;	height = req_height;    } else {	screen_width = gdk_screen_width();	width = screen_width * 3/4;	height = width * 3/4;    }    /*     * Setup some GTK+ defaults     */    screen.tooltips = gtk_tooltips_new();            screen.background = alloc_color(0, 0, 0, "black");    screen.zoom_outline_color  = alloc_color(0, 0, 0, "gray");    screen.dist_measure_color  = alloc_color(0, 0, 0, "lightblue");    /*     * Set console error log handler. The default gives us error levels in     * in the beginning which I don't want.     */    g_log_set_handler (NULL, 		       G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION | G_LOG_LEVEL_MASK, 		       gerbv_console_log_handler, NULL);     /* Set default unit to the configured default */    screen.unit = GERBV_DEFAULT_UNIT;    /*     * Main window      */    win_title = (char *)malloc(strlen(WIN_TITLE) + strlen(VERSION) + 1);    memset(win_title, 0, strlen(WIN_TITLE) + strlen(VERSION) + 1);    strncpy(win_title, WIN_TITLE, strlen(WIN_TITLE));    strncat(win_title, VERSION, strlen(VERSION));    main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);    gtk_window_set_title(GTK_WINDOW(main_win), win_title);    gtk_signal_connect(GTK_OBJECT(main_win), "delete_event", destroy, NULL);    gtk_signal_connect(GTK_OBJECT(main_win), "destroy", destroy, NULL);    free(win_title);    /*      * vbox contains menubar and hbox     */    vbox = gtk_vbox_new(FALSE, 0);    gtk_container_add(GTK_CONTAINER(main_win), vbox);        create_menubar(main_win, &menubar);    gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);        /*      * hbox contains drawing area and image select area     */    hbox = gtk_hbox_new(FALSE, 0);        /*     * Create drawing area     */    screen.drawing_area = create_drawing_area(width, height);    gtk_box_pack_start(GTK_BOX(hbox), screen.drawing_area, TRUE, TRUE, 0);        /*     * Build layer buttons with popup menus     */    create_popupmenu(&screen.popup_menu);    gtk_box_pack_start(GTK_BOX(hbox), create_layer_buttons(MAX_FILES), 		       FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);    /*     * Add status bar (three sections: messages, abs and rel coords)     */    hbox = gtk_hbox_new(FALSE, 0);    screen.statusbar.msg = gtk_label_new("");    gtk_label_set_justify(GTK_LABEL(screen.statusbar.msg), GTK_JUSTIFY_LEFT);    textStyle = gtk_style_new();#ifndef USE_GTK2    textStyle->font = gdk_font_load(setup.status_fontname);#else    textStyle->font_desc = pango_font_description_from_string(setup.status_fontname);#endif    gtk_widget_set_style(GTK_WIDGET(screen.statusbar.msg), textStyle);    screen.statusbar.msgstr[0] = '\0';    screen.statusbar.coordstr[0] = '\0';    screen.statusbar.diststr[0] = '\0';    gtk_box_pack_start(GTK_BOX(hbox), screen.statusbar.msg, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);    /*     * If project is given, load that one and use it for files and colors.     * Else load files (eventually) given on the command line.     * This limits you to either give files on the commandline or just load     * a project.     */    if (project_filename) {	project_list_t *project_list;	project_list = read_project_file(project_filename);		if (project_list) {	    load_project(project_list);	    if (screen.project)		free(screen.project);	    screen.project = project_filename;	} else {	    GERB_MESSAGE("Failed to load project\n");	}    } else {	for(i = optind ; i < argc; i++)	    if (open_image(argv[i], i - optind, FALSE) == -1)		exit(-1);    }    /*     * Set gtk error log handler     */    g_log_set_handler (NULL, 		       G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION | G_LOG_LEVEL_MASK, 		       gerbv_gtk_log_handler, NULL);     /*     * Connect all events on drawing area      */        gtk_signal_connect(GTK_OBJECT(screen.drawing_area), "expose_event",		       GTK_SIGNAL_FUNC(expose_event), NULL);    gtk_signal_connect(GTK_OBJECT(screen.drawing_area),"configure_event",		       GTK_SIGNAL_FUNC(configure_event), NULL);    gtk_signal_connect(GTK_OBJECT(screen.drawing_area), "motion_notify_event",		       GTK_SIGNAL_FUNC(motion_notify_event), NULL);    gtk_signal_connect(GTK_OBJECT(screen.drawing_area), "button_press_event",		       GTK_SIGNAL_FUNC(button_press_event), NULL);    gtk_signal_connect(GTK_OBJECT(screen.drawing_area), "button_release_event",		       GTK_SIGNAL_FUNC(button_release_event), NULL);    gtk_signal_connect_after(GTK_OBJECT(main_win), "key_press_event",		       GTK_SIGNAL_FUNC(key_press_event), NULL);    gtk_signal_connect_after(GTK_OBJECT(main_win), "key_release_event",		       GTK_SIGNAL_FUNC(key_release_event), NULL);#ifdef USE_GTK2    gtk_signal_connect_after(GTK_OBJECT(main_win), "scroll_event",		       GTK_SIGNAL_FUNC(scroll_event), NULL);#endif    gtk_widget_set_events(screen.drawing_area, GDK_EXPOSURE_MASK			  | GDK_LEAVE_NOTIFY_MASK			  | GDK_BUTTON_PRESS_MASK			  | GDK_BUTTON_RELEASE_MASK			  | GDK_KEY_PRESS_MASK			  | GDK_KEY_RELEASE_MASK			  | GDK_POINTER_MOTION_MASK			  | GDK_POINTER_MOTION_HINT_MASK#ifdef USE_GTK2			  | GDK_SCROLL_MASK#endif			  );    gtk_widget_show_all(main_win);    set_window_icon(main_win);    /* It seems this has to be done after the button is shown for       the first time, or we get a segmentation fault */    if (project_filename)	all_layers_on(NULL, NULL);    else	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen.layer_button[0]),				     TRUE);    gtk_main();        return 0;} /* main */