From: Darren S. <ds...@us...> - 2005-06-03 18:37:03
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31739/src Modified Files: engine.c http.c key_events.c mediamarks.c menu.c noskin_window.c play_item.c script_engine.c ui.c utils.c utils.h Log Message: Kill a few small memory leaks. Make more use of foreach_glist() (it works for any struct with a 'next' ptr.) Swap a few function calls to help the compiler a bit. A few other small tweaks (replacement with equivalent, smaller, code). Mark a few variables const. Index: engine.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/engine.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- engine.c 4 May 2005 01:02:10 -0000 1.13 +++ engine.c 3 Jun 2005 18:36:52 -0000 1.14 @@ -136,6 +136,7 @@ cfgfilename = g_strconcat (g_get_home_dir(), "/.gxine/config", NULL); xine_config_load (xine, cfgfilename); + free (cfgfilename); xine_engine_set_param (xine, XINE_ENGINE_PARAM_VERBOSITY, verbosity); xine_init (xine); Index: http.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/http.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- http.c 16 Jan 2005 17:38:34 -0000 1.17 +++ http.c 3 Jun 2005 18:36:52 -0000 1.18 @@ -217,59 +217,50 @@ static int http_basicauth (const char *user, const char *password, char* dest, int len) { - static char *enctable="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + static const char enctable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; char *tmp; char *sptr; char *dptr; - int totlen; - int enclen; int count; - totlen = strlen (user) + 1; - if(password != NULL) - totlen += strlen (password); - - enclen = ((totlen + 2) / 3 ) * 4 + 1; + count = strlen (user) + 1; + if (password != NULL) + count += strlen (password); - if (len < enclen) + if (len < ((count + 2) / 3 ) * 4 + 1) return -1; - tmp = malloc (sizeof(char) * (totlen + 1)); - strcpy (tmp, user); - strcat (tmp, ":"); - if (password != NULL) - strcat (tmp, password); - - count = strlen(tmp); - sptr = tmp; + sptr = tmp = g_strconcat (user, ":", password, NULL); dptr = dest; while (count >= 3) { - dptr[0] = enctable[(sptr[0] & 0xFC) >> 2]; - dptr[1] = enctable[((sptr[0] & 0x3) << 4) | ((sptr[1] & 0xF0) >> 4)]; - dptr[2] = enctable[((sptr[1] & 0x0F) << 2) | ((sptr[2] & 0xC0) >> 6)]; - dptr[3] = enctable[sptr[2] & 0x3F]; + *dptr++ = enctable[(sptr[0] & 0xFC) >> 2]; + *dptr++ = enctable[((sptr[0] & 0x3) << 4) | ((sptr[1] & 0xF0) >> 4)]; + *dptr++ = enctable[((sptr[1] & 0x0F) << 2) | ((sptr[2] & 0xC0) >> 6)]; + *dptr++ = enctable[sptr[2] & 0x3F]; count -= 3; sptr += 3; - dptr += 4; } if (count > 0) { - dptr[0] = enctable[(sptr[0] & 0xFC) >> 2]; - dptr[1] = enctable[(sptr[0] & 0x3) << 4]; - dptr[2] = '='; + *dptr++ = enctable[(sptr[0] & 0xFC) >> 2]; - if (count > 1) { - dptr[1] = enctable[((sptr[0] & 0x3) << 4) | ((sptr[1] & 0xF0) >> 4)]; - dptr[2] = enctable[(sptr[1] & 0x0F) << 2]; + if (count > 1) + { + *dptr++ = enctable[((sptr[0] & 0x3) << 4) | ((sptr[1] & 0xF0) >> 4)]; + *dptr++ = enctable[(sptr[1] & 0x0F) << 2]; + } + else + { + *dptr++ = enctable[(sptr[0] & 0x3) << 4]; + *dptr++ = '='; } - dptr[3] = '='; - dptr += 4; + *dptr++ = '='; } dptr[0] = '\0'; - free(tmp); + free (tmp); return 0; } @@ -299,8 +290,8 @@ if (http_parse_url (this->proxybuf, &this->proxyuser, &this->proxypassword, &this->proxyhost, &this->proxyport, NULL)) { - free (this); report_error (mrl, _("URL parse error")); + free (this); return NULL; } @@ -310,8 +301,8 @@ if (this->proxyuser != NULL) if (http_basicauth (this->proxyuser, this->proxypassword, this->proxyauth, BUFSIZE)) { - free (this); report_error (mrl, _("proxy authentication error")); + free (this); return NULL; } } @@ -328,8 +319,8 @@ if (this->user != NULL) if (http_basicauth (this->user, this->password, this->auth, BUFSIZE)) { - free (this); report_error (mrl, _("proxy authentication error")); + free (this); return NULL; } @@ -348,8 +339,8 @@ this->curpos = 0; if (this->fh == -1) { - free (this); report_error (mrl, _("host connect error")); + free (this); return NULL; } @@ -385,8 +376,8 @@ if (write (this->fh, request, strlen(request)) != strlen(request)) { free (request); - free (this); report_error (mrl, _("couldn't send request")); + free (this); return NULL; } @@ -406,8 +397,8 @@ printf ("http: EAGAIN\n"); continue; default: - free (this); report_error (mrl, _("read error")); + free (this); return NULL; } } @@ -432,23 +423,23 @@ if (sscanf(this->buf, "HTTP/%d.%d %d %[^\015\012]", &httpver, &httpsub, &httpcode, httpstatus) != 4) { - free (this); report_error (mrl, _("invalid HTTP response")); + free (this); return NULL; } if (httpcode >= 300 && httpcode < 400) { logprintf ("http: 3xx redirection not implemented: >%d %s<\n", httpcode, httpstatus); - free (this); report_error (mrl, _("HTTP 3xx redirection not implemented")); + free (this); return NULL; } if (httpcode < 200 || httpcode >= 300) { logprintf ("http: http status not 2xx: >%d %s<\n", httpcode, httpstatus); - free (this); report_error (mrl, _("HTTP status is not 2xx")); + free (this); return NULL; } } else { @@ -466,8 +457,8 @@ } if (!strncasecmp(this->buf, "Location: ", 10)) { logprintf ("http: Location redirection not implemented\n"); - free (this); report_error (mrl, _("HTTP 'Location:' redirection not implemented")); + free (this); return NULL; } } Index: key_events.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/key_events.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- key_events.c 2 Jun 2005 22:16:52 -0000 1.68 +++ key_events.c 3 Jun 2005 18:36:52 -0000 1.69 @@ -500,7 +500,7 @@ key_binding_t binding = { 0 }; int i; - while (node) { + foreach_glist (node, node) if (!strcasecmp (node->name, "command")) binding.cmd = node->data; else if (!strcasecmp (node->name, "description")) @@ -510,9 +510,6 @@ else if (!strcasecmp (node->name, "state")) binding.state = atoi (node->data); - node = node->next; - } - if (!binding.cmd || !binding.keyval) return; @@ -542,27 +539,23 @@ gchar *kbfile = read_entire_file (fname, NULL); int version = 1; - if (kbfile) { + if (kbfile) + { xml_node_t *node; - xml_parser_init (kbfile, strlen (kbfile), XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree (&node)>=0) { - - if (!strcasecmp (node->name, "gxinekb")) { - - xml_property_t *prop = node->props; - - while (prop) - { + if (xml_parser_build_tree (&node) >= 0) + { + if (!strcasecmp (node->name, "gxinekb")) + { + xml_property_t *prop; + foreach_glist (prop, node->props) if (!strcasecmp (prop->name, "version") && prop->value) { version = atoi (prop->value); logprintf ("key_events: keybindings version %d\n", version); break; } - prop = prop->next; - } if (version < 2) { @@ -577,16 +570,9 @@ load_default_kb (); } - node = node->child; - while (node) { - if (!strcasecmp (node->name, "KEYBINDING")) { - + foreach_glist (node, node->child) + if (!strcasecmp (node->name, "KEYBINDING")) xml2kb (node->child, version); - - } - node = node->next; - } - } else { printf (_("key_events: error, %s is not a valid gxine keybindings file\n"), fname); @@ -785,7 +771,6 @@ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (kb_binding_quote))) { -printf("%04x %02x\n", event->keyval, event->state); if (event->state == 0) { switch (event->keyval) @@ -867,101 +852,37 @@ modify_key_binding (&catch_key_iter, key_binding, &editkey); } - -static JSBool js_input_up (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_up"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_UP; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_down (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_down"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_DOWN; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_left (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_left"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_LEFT; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_right (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ +static JSBool js_xine_event (int type +#ifdef LOG + , const char *log +#endif + ) +{ xine_event_t event; - - se_log_fncall ("input_right"); - - event.type = 0; + se_log_fncall (log); + event.type = type; event.data = NULL; event.data_length = 0; - - event.type = XINE_EVENT_INPUT_RIGHT; - xine_event_send (stream, &event); - return JS_TRUE; } -static JSBool js_input_select (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { +#ifndef LOG +#define js_xine_event(T,L) (js_xine_event)((T)) +#endif - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_select"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_SELECT; - - xine_event_send (stream, &event); +#define JS_XINE_EVENT(L,T) \ + static JSBool js_##L (JSContext *cx, JSObject *obj, uintN argc, \ + jsval *argv, jsval *rval) \ + { \ + return js_xine_event (XINE_EVENT_##T, #L); \ + } - return JS_TRUE; -} +JS_XINE_EVENT (input_up, INPUT_UP); +JS_XINE_EVENT (input_down, INPUT_DOWN); +JS_XINE_EVENT (input_left, INPUT_LEFT); +JS_XINE_EVENT (input_right, INPUT_RIGHT); +JS_XINE_EVENT (input_select, INPUT_SELECT); static JSBool js_input_menu (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { @@ -994,100 +915,11 @@ return JS_TRUE; } -static JSBool js_input_menu1 (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_menu1"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_MENU1; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_menu2 (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_menu2"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_MENU2; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_menu3 (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_menu3"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_MENU3; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_previous (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_previous"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_PREVIOUS; - - xine_event_send (stream, &event); - - return JS_TRUE; -} - -static JSBool js_input_next (JSContext *cx, JSObject *obj, uintN argc, - jsval *argv, jsval *rval) { - - /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */ - xine_event_t event; - - se_log_fncall ("input_next"); - - event.type = 0; - event.data = NULL; - event.data_length = 0; - - event.type = XINE_EVENT_INPUT_NEXT; - - xine_event_send (stream, &event); - - return JS_TRUE; -} +JS_XINE_EVENT (input_menu1, INPUT_MENU1); +JS_XINE_EVENT (input_menu2, INPUT_MENU2); +JS_XINE_EVENT (input_menu3, INPUT_MENU3); +JS_XINE_EVENT (input_previous, INPUT_PREVIOUS); +JS_XINE_EVENT (input_next, INPUT_NEXT); static JSBool js_keybindings_show (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { Index: mediamarks.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/mediamarks.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- mediamarks.c 2 Jun 2005 22:16:53 -0000 1.50 +++ mediamarks.c 3 Jun 2005 18:36:52 -0000 1.51 @@ -189,8 +189,7 @@ static void get_items (xml_node_t *node, int depth, GtkTreeIter *parent) { /* assumption: *one* of (depth == 0) or (parent == NULL) */ - while (node) { - + foreach_glist (node, node) if (!strcasecmp (node->name, "sub")) { GtkTreeIter iter; @@ -214,9 +213,6 @@ } else { printf (_("mediamarks: error, unknown node type %s\n"), node->name); } - - node = node->next; - } } static void load_new_file (xml_node_t *node) { @@ -253,79 +249,85 @@ static void load_old_file (char *fname) { FILE *f; - int depth; GtkTreeIter parent; GtkTreeIter iter; gtk_tree_model_get_iter_first ( GTK_TREE_MODEL (mm_store), &parent); f = fopen (fname, "r"); - if (f) { - - depth = 0; - - while (1) { - char *id, *str; + if (f) + { + int depth = 0; - id = read_line (f); + for (;;) + { + char *id = read_line (f); if (!id) break; - if (!strncmp (id, "<sub>", 5)) { - + if (!strncmp (id, "<sub>", 5)) + { gtk_tree_store_append (mm_store, &iter, depth ? &parent : NULL); gtk_tree_store_set (mm_store, &iter, 0, &id[5], -1); parent = iter; depth++; - - } else if (!strncmp (id, "</sub>", 6)) { - + } + else if (!strncmp (id, "</sub>", 6)) + { /* sub-tree ends here */ - gtk_tree_model_iter_parent (GTK_TREE_MODEL (mm_store), &iter, &parent); - depth--; - if (depth<0) { - + if (--depth < 0) + { printf (_("mediamarks: media marks file %s corrupted - ignoring rest of file\n"), fname); + free (id); return; } parent = iter; - - } else { - + } + else + { play_item_t *play_item; - char *mrl; + char *mrl, *str; int time = 0; mrl = read_line (f); if (!mrl) + { + free (id); break; + } str = read_line (f); - if (!str) + { + free (mrl); + free (id); break; - sscanf (str, "%d", &time); + } + sscanf (str, "%d", &time); play_item = play_item_new (id, mrl, time); gtk_tree_store_append (mm_store, &iter, depth ? &parent : NULL); gtk_tree_store_set (mm_store, &iter, 0, id, 1, mrl, 2, play_item, -1); + + free (str); + free (mrl); } /* discard newline */ - str = read_line (f); - if (!str) + free (id); + id = read_line (f); + if (!id) break; + free (id); } fclose (f); - } else { - - printf (_("mediamarks: load failed!\n")); - } + else + printf (_("mediamarks: load failed!\n")); } static void cat_response_cb (GtkDialog* widget, int response, gpointer data) Index: menu.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/menu.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- menu.c 27 May 2005 19:19:08 -0000 1.50 +++ menu.c 3 Jun 2005 18:36:53 -0000 1.51 @@ -86,7 +86,7 @@ static void autoplay_cb (GtkAction *action, gpointer data) { - char **mrls, *mrl; + char **mrls; int n, i, pos; mrls = xine_get_autoplay_mrls (xine, data, &n); @@ -100,16 +100,12 @@ return; } - mrl = mrls[0]; i = 0; pos = -1; - while (mrl) { - - if (pos<0) - pos = playlist_add_mrl (mrl, -1); + pos = -1; + for (i = 0; mrls[i]; ++i) + if (pos < 0) + pos = playlist_add_mrl (mrls[i], -1); else - playlist_add_mrl (mrl, -1); - - mrl = mrls[++i]; - } + playlist_add_mrl (mrls[i], -1); playlist_play (pos); } Index: noskin_window.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/noskin_window.c,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- noskin_window.c 2 Jun 2005 22:16:53 -0000 1.60 +++ noskin_window.c 3 Jun 2005 18:36:53 -0000 1.61 @@ -66,14 +66,12 @@ * callbacks */ -static void control_cb (GtkWidget* widget, gpointer data) { - - char *cmd = (char *) data; - +static void control_cb (GtkWidget* widget, gpointer data) +{ if (no_recursion) return; - engine_exec (cmd, NULL, NULL); + engine_exec (data, NULL, NULL); /* take focus away from this button (pressing 'space' for pause tends to behave strangely otherwise */ @@ -163,12 +161,12 @@ { have_video = hv_new; have_audio = ha_new; - if (have_video) { + if (hv_new) { logprintf ("gxine: stream has video\n"); vis_hide (GTK_VIDEO(gtv), &audio_port); gtk_widget_show (gtv); } - else if (!have_audio) + else if (!ha_new) { logprintf ("gxine: stream has no audio\n"); gtk_widget_hide (gtv); Index: play_item.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/play_item.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- play_item.c 2 Jun 2005 22:16:53 -0000 1.25 +++ play_item.c 3 Jun 2005 18:36:53 -0000 1.26 @@ -173,8 +173,7 @@ play_item->options = NULL; play_item->mrl = NULL; - while (node) { - + foreach_glist (node, node) if (!strcasecmp (node->name, "title")) { play_item->untitled = xml_parser_get_property (node, "default") != NULL; play_item->title = strdup (node->data); @@ -188,31 +187,19 @@ } else printf (_("play_item: error while loading, unknown node %s\n"), node->name); - node = node->next; - } - return play_item; } -void play_item_play (play_item_t *play_item) { - - GList *option; +void play_item_play (play_item_t *play_item) +{ + GList *option; /* * execute any optional commands which may be associated with this play item * (e.g. set volume etc.) */ - - option = play_item->options; - - while (option) { - - char *cmd = (char *) option->data; - - engine_exec (cmd, NULL, NULL); - - option = g_list_next (option); - } + foreach_glist (option, play_item->options) + engine_exec (option->data, NULL, NULL); player_launch (play_item->title, play_item->mrl, 0, play_item->start_time); } Index: script_engine.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/script_engine.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- script_engine.c 2 Jun 2005 22:16:54 -0000 1.48 +++ script_engine.c 3 Jun 2005 18:36:53 -0000 1.49 @@ -281,9 +281,10 @@ static char *show_help_int (se_t *se, se_o_t *obj, se_group_t selector) { - const GList *objs = obj->functions; + const GList *objs; char *help = NULL; - while (objs) + + foreach_glist (objs, obj->functions) { se_f_t *cmd = objs->data; if (cmd->group == selector) @@ -301,11 +302,9 @@ cmd->funchelp ? : "", cmd->funchelp ? " */" : ""); free (prefix); } - objs = objs->next; } - objs = obj->children; - while (objs) + foreach_glist (objs, obj->children) { char *group = show_help_int (se, objs->data, selector); if (group) @@ -313,11 +312,9 @@ asreprintf (&help, "%s%s", help ? : "", group); free (group); } - objs = objs->next; } - objs = obj->children; - while (objs) + foreach_glist (objs, obj->children) { se_o_t *o = objs->data; if (o->group == selector) @@ -335,7 +332,6 @@ o->help ? " */" : ""); free (prefix); } - objs = objs->next; } return help; @@ -367,9 +363,9 @@ while (group_id[++i]) { char *help = NULL; - const GSList *pse = se_chain; + const GSList *pse; - while (pse) + foreach_glist (pse, se_chain) { char *group = show_help_int (se, ((se_t *)pse->data)->g, i); if (group) @@ -378,7 +374,6 @@ gettext (group_id[i]), group); free (group); } - pse = pse->next; } if (!help) @@ -757,13 +752,12 @@ se_o_t *se_find_object (se_t *se, se_o_t *parent, const gchar *name) { - GList *objs = parent ? parent->children : se->g->children; - while (objs) + GList *objs; + foreach_glist (objs, parent ? parent->children : se->g->children) { se_o_t *o = objs->data; if (!strcmp (o->id, name)) return o; - objs = objs->next; } return NULL; } Index: ui.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/ui.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ui.c 27 May 2005 19:19:08 -0000 1.14 +++ ui.c 3 Jun 2005 18:36:53 -0000 1.15 @@ -476,11 +476,11 @@ void ui_preferences_register (xine_t *this) { - static char *experience_labels[] = { + static const char *experience_labels[] = { N_("Beginner"), N_("Advanced"), N_("Expert"), N_("Master of the known universe"), NULL }; - static char *tbar_pos_labels[] = { + static const char *tbar_pos_labels[] = { N_("Top, hidden"), N_("Bottom, hidden"), N_("Top, visible"), N_("Bottom, visible"), NULL Index: utils.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/utils.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- utils.c 2 Jun 2005 22:16:54 -0000 1.55 +++ utils.c 3 Jun 2005 18:36:53 -0000 1.56 @@ -147,7 +147,7 @@ return pix; } -void window_show (GtkWidget *widget, GtkWidget *parent) +void window_show (GtkWidget *const widget, GtkWidget *const parent) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WINDOW (widget)); @@ -158,15 +158,12 @@ gdk_window_raise (widget->window); } -static void response_cb (GtkWidget *dialog, gint response, gpointer data) { - char *msg; - - msg = g_object_get_data (G_OBJECT (dialog), "msg"); - g_free (msg); +static void response_cb (GtkWidget *dialog, gint response, gpointer data) +{ + free (g_object_get_data (G_OBJECT (dialog), "msg")); gtk_widget_destroy (dialog); } - void v_display_message (const gchar *title, GtkMessageType type, const gchar *fmt, va_list ap) { @@ -375,19 +372,13 @@ return *str = ret; } -char *unique_name (char *base) { - - static int i = 0; - char *name; - - name = malloc (strlen(base)+10); - - sprintf (name, "%s_%d", base, i); - - i++; - - return name; +#ifdef EXP_STUFF +char *unique_name (char *base) +{ + static int i = 0; + return g_strdup_printf ("%s_%d", base, ++i); } +#endif void do_pending_events (void) { Index: utils.h =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/utils.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- utils.h 2 Jun 2005 22:16:54 -0000 1.31 +++ utils.h 3 Jun 2005 18:36:53 -0000 1.32 @@ -74,7 +74,9 @@ char *asreprintf (char **str, const char *fmt, ...); +#ifdef EXP_STUFF char *unique_name (char *base); +#endif void do_pending_events (void); |