Skip to content

Commit

Permalink
Removed depreciated g_mutex_new
Browse files Browse the repository at this point in the history
  • Loading branch information
RickyRockRat committed Apr 11, 2019
1 parent 1484aee commit 73f28da
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/attr_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void remove_deleted_items(struct history_info *h)
{
if(NULL != h && NULL != h->delete_list){/**have a list of items to delete. */
GList *i;
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
/*g_print("Deleting items\n"); */
for (i=h->delete_list; NULL != i; i=i->next){
struct s_item_info *it=(struct s_item_info *)i->data;
Expand All @@ -265,7 +265,7 @@ void remove_deleted_items(struct history_info *h)
g_free(it);
}
h->delete_list=NULL;
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
if (get_pref_int32("save_history"))
save_history();
}
Expand Down
32 changes: 16 additions & 16 deletions src/history.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void read_history_old ()
if (history_file) {
/* Read the size of the first item */
gint size=1;
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
/* Continue reading until size is 0 */
while (size) {
struct history_item *c;
Expand All @@ -102,7 +102,7 @@ void read_history_old ()
/* Close file and reverse the history to normal */
fclose(history_file);
history_list = g_list_reverse(history_list);
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ void read_history ()
}
if(dbg) g_printf("History Magic OK. Reading\n");
/* Continue reading until size is 0 */
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
while (size) {
struct history_item *c;
if (fread(&size, 4, 1, history_file) != 1)
Expand Down Expand Up @@ -229,7 +229,7 @@ void read_history ()
/* Close file and reverse the history to normal */
fclose(history_file);
history_list = g_list_reverse(history_list);
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
}
if(dbg) g_printf("History read done\n");
}
Expand Down Expand Up @@ -278,7 +278,7 @@ void save_history()
}
memcpy(magic,history_magics[HISTORY_VERSION-1],strlen(history_magics[HISTORY_VERSION-1]));
fwrite(magic,HISTORY_MAGIC_SIZE,1,history_file);
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
/* Write each element to a binary file */
for (element = history_list; element != NULL; element = element->next) {
struct history_item *c;
Expand All @@ -297,7 +297,7 @@ void save_history()
}

}
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
/* Write 0 to indicate end of file */
gint end = 0;
fwrite(&end, 4, 1, history_file);
Expand Down Expand Up @@ -370,7 +370,7 @@ void append_item(gchar* item, int checkdup, gint iflags, gint itype)
struct history_item *c=NULL;
if(NULL == item)
return;
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
/**delete if HIST_DEL flag is set. */
if( checkdup & HIST_CHECKDUP){
node=is_duplicate(item, checkdup & HIST_DEL, &flags);
Expand Down Expand Up @@ -400,7 +400,7 @@ void append_item(gchar* item, int checkdup, gint iflags, gint itype)
/*g_printf("Append '%s'\n",item); */
/* Prepend new item */
history_list = g_list_prepend(history_list, NULL ==element?c:element->data);
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
/* Shorten history if necessary */
truncate_history();
}
Expand All @@ -415,7 +415,7 @@ void delete_duplicate(gchar* item)
GList* element;
int p=get_pref_int32("persistent_history");
/* Go through each element compare each */
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
for (element = history_list; element != NULL; element = element->next) {
struct history_item *c;
c=(struct history_item *)element->data;
Expand All @@ -428,7 +428,7 @@ void delete_duplicate(gchar* item)
}
}
}
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
}

/***************************************************************************/
Expand All @@ -442,7 +442,7 @@ void truncate_history()
{
int p=get_pref_int32("persistent_history");
if (history_list) {
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
guint ll=g_list_length(history_list);
guint lim=get_pref_int32("history_limit");
if(ll > lim){ /* Shorten history if necessary */
Expand All @@ -456,7 +456,7 @@ void truncate_history()
}
}
}
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
/* Save changes */
if (get_pref_int32("save_history"))
save_history();
Expand Down Expand Up @@ -489,7 +489,7 @@ gpointer get_last_item()
****************************************************************************/
void clear_history( void )
{
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
if( !get_pref_int32("persistent_history")){
g_list_free(history_list);
history_list = NULL;
Expand All @@ -503,7 +503,7 @@ void clear_history( void )
history_list=g_list_remove(history_list,c);
}
}
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
if (get_pref_int32("save_history"))
save_history();
}
Expand All @@ -519,7 +519,7 @@ int save_history_as_text(gchar *path)
if (fp) {
gint i;
GList* element;
g_mutex_lock(hist_lock);
g_mutex_lock(&hist_lock);
/* Write each element to file */
for (i=0,element = history_list; element != NULL; element = element->next) {
struct history_item *c;
Expand All @@ -530,7 +530,7 @@ int save_history_as_text(gchar *path)
fprintf(fp,"NHIST_%04d %s\n",i,c->text);
++i;
}
g_mutex_unlock(hist_lock);
g_mutex_unlock(&hist_lock);
fclose(fp);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static AppIndicator *indicator=NULL;
static GtkWidget *indicator_menu = NULL;
#endif
static GtkStatusIcon *status_icon=NULL;
GMutex *hist_lock=NULL;
GMutex hist_lock;
static gboolean actions_lock = FALSE;
static int show_icon=0;
static int have_appindicator=0; /**if set, we have a running indicator-appmenu */
Expand Down Expand Up @@ -2257,7 +2257,7 @@ static void parcellite_init()
if(FALSE ==g_thread_supported()){
g_fprintf(stderr,"g_thread not init!\n");
}
hist_lock= g_mutex_new();
g_mutex_init(&hist_lock);

show_icon=!get_pref_int32("no_icon");
/* Read history */
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "preferences.h"
G_BEGIN_DECLS

extern GMutex *hist_lock;
extern GMutex hist_lock;

#define ACTIONS_TAB 2
#define POPUP_DELAY 100
Expand Down

0 comments on commit 73f28da

Please sign in to comment.