mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-10 15:44:41 -05:00
Replace all qsorts.
This commit is contained in:
parent
dc356d81c4
commit
f88cfacfde
4 changed files with 11 additions and 11 deletions
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue