summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQC <qball@gmpclient.org>2015-07-05 09:47:55 +0200
committerQC <qball@gmpclient.org>2015-07-05 09:47:55 +0200
commitf88cfacfde7719cdaba2528b8d1f98c4674d2e94 (patch)
treea9b19a1882b7c431fb7a51137d389ba955c28467
parentdc356d81c4869af46f20487579f89c9c853c9f04 (diff)
Replace all qsorts.
-rw-r--r--source/dialogs/run.c6
-rw-r--r--source/dialogs/ssh.c4
-rw-r--r--source/history.c4
-rw-r--r--source/i3-support.c8
4 files changed, 11 insertions, 11 deletions
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index 8ea7395d..5950b25b 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -105,7 +105,7 @@ static void delete_entry ( const char *cmd )
g_free ( path );
}
-static int sort_func ( const void *a, const void *b )
+static int sort_func ( const void *a, const void *b, void *data __attribute__( ( unused ) ) )
{
const char *astr = *( const char * const * ) a;
const char *bstr = *( const char * const * ) b;
@@ -241,7 +241,7 @@ static char ** get_apps ( unsigned int *length )
}
// TODO: check this is still fast enough. (takes 1ms on laptop.)
if ( ( *length ) > num_favorites ) {
- qsort ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func );
+ g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func, NULL );
}
g_free ( path );
@@ -256,7 +256,7 @@ static char ** get_apps ( unsigned int *length )
if ( ( *length ) > num_favorites ) {
- qsort ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func );
+ g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func, NULL );
}
// Reduce array length;
( *length ) -= removed;
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 0cafefa3..9b688db3 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -103,7 +103,7 @@ static void delete_ssh ( const char *cmd )
history_remove ( path, cmd );
g_free ( path );
}
-static int ssh_sort_func ( const void *a, const void *b )
+static int ssh_sort_func ( const void *a, const void *b, void *data __attribute__( ( unused ) ) )
{
const char *astr = *( const char * const * ) a;
const char *bstr = *( const char * const * ) b;
@@ -257,7 +257,7 @@ static char ** get_ssh ( unsigned int *length )
// TODO: check this is still fast enough. (takes 1ms on laptop.)
if ( ( *length ) > num_favorites ) {
- qsort ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), ssh_sort_func );
+ g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), ssh_sort_func, NULL );
}
g_free ( path );
diff --git a/source/history.c b/source/history.c
index 68ac36b5..b86a0816 100644
--- a/source/history.c
+++ b/source/history.c
@@ -43,7 +43,7 @@ typedef struct __element
char name[HISTORY_NAME_LENGTH];
}_element;
-static int __element_sort_func ( const void *ea, const void *eb )
+static int __element_sort_func ( const void *ea, const void *eb, void *data __attribute__( ( unused ) ) )
{
_element *a = *(_element * *) ea;
_element *b = *(_element * *) eb;
@@ -56,7 +56,7 @@ static void __history_write_element_list ( FILE *fd, _element **list, unsigned i
return;
}
// Sort the list before writing out.
- qsort ( list, length, sizeof ( _element* ), __element_sort_func );
+ g_qsort_with_data ( list, length, sizeof ( _element* ), __element_sort_func, NULL );
// Get minimum index.
int min_value = list[length - 1]->index;
diff --git a/source/i3-support.c b/source/i3-support.c
index bd9a8678..c4759bbb 100644
--- a/source/i3-support.c
+++ b/source/i3-support.c
@@ -53,11 +53,11 @@ void i3_support_focus_window ( Window id )
int s, len;
ssize_t t;
struct sockaddr_un remote;
- size_t upm = sizeof(remote.sun_path);
+ size_t upm = sizeof ( remote.sun_path );
char command[upm];
- if ( strlen ( i3_socket_path ) > upm) {
- fprintf ( stderr, "Socket path is too long. %zd > %lu\n", strlen ( i3_socket_path ), upm);
+ if ( strlen ( i3_socket_path ) > upm ) {
+ fprintf ( stderr, "Socket path is too long. %zd > %lu\n", strlen ( i3_socket_path ), upm );
return;
}
@@ -67,7 +67,7 @@ void i3_support_focus_window ( Window id )
}
remote.sun_family = AF_UNIX;
- g_strlcpy ( remote.sun_path, i3_socket_path, upm);
+ g_strlcpy ( remote.sun_path, i3_socket_path, upm );
len = strlen ( remote.sun_path ) + sizeof ( remote.sun_family );
if ( connect ( s, ( struct sockaddr * ) &remote, len ) == -1 ) {