[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Denemo-devel] use of g_strsplit
From: |
Richard Shann |
Subject: |
[Denemo-devel] use of g_strsplit |
Date: |
Sun, 13 Dec 2009 15:54:06 +0000 |
Jeremiah
this piece of code in device_manager.c is faulty
gchar **device_path_str = g_strsplit(path_string,":",2);
device_number = atoi(device_path_str[0]);
if (device_path_str[1]){
port_number = atoi(device_path_str[1]);
if(!rename_jack_midi_port(device_number, port_number, new_name))
gtk_tree_store_set (treestore, &iter, 0, new_name, -1);
} else {
g_debug("can't change device name yet");
}
g_free(device_path_str);
you would need to use a special function to free the array
device_path_str - it's an array of strings. Instead of all this, just
use
gchar * g_strrstr (const gchar *haystack, const gchar *needle);
with haystack = path_string and
with needle=":" this will give you a pointer into the path_string
pointing to the ':' character so you can do aoi(that pointer +1)
(well, if these are completely unchecked strings you are dealing with
then g_strrstr_len () would be better).
Richard
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Denemo-devel] use of g_strsplit,
Richard Shann <=