/* ***********************IMPORTANT *********************************************
 *  Copyright (C) 2004-2007 Thierry Lagarde <tlagarde@users.sourceforge.net>
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License.
 *
 *
 *                      ********************
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *
 *                      ********************
 *
 *
 * You are highly encouraged to send your changes to <tlagarde@users.sourceforge.net>
 * for possible incorporation into the main distribution.
 * By sending these changes to <tlagarde@users.sourceforge.net>,
 * it is assumed that you are offering <tlagarde@users.sourceforge.net>
 * the unlimited, non-exclusive right to reuse, modify, and relicense the code.
 *
 *
 *                      ********************
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **************************************************************************************/
#ifndef         __MACRO
#define         __MACRO

#include <glib.h>
#include <stdlib.h>
#include "Semaphore.h"



#define G_LIST_APPEND(_glist,_donnee) 				G_STMT_START{			\
		_glist = g_list_append (_glist, _donnee);							\
		}G_STMT_END
		
#define G_LIST_REMOVE(_glist,_donnee) 				G_STMT_START{			\
		_glist = g_list_remove (_glist, _donnee);							\
		}G_STMT_END
		
#define MALLOC(_pointeur,_taille) 				G_STMT_START{				\
		if( (_pointeur) != NULL ) { 										\
     		printf("Malloc pointeur!=NULL :%s : %d\n",__FILE__,__LINE__);				\
		} 																					\					
		(_pointeur) = malloc (_taille);										\
		if( (_pointeur) == NULL ) { 										\
     		printf("Malloc Failed :%s : %d\n",__FILE__,__LINE__);				\
     		exit(EXIT_FAILURE); 											\
		} 																	\
		bzero (_pointeur, (_taille));										\
		}G_STMT_END

	
#define REALLOC(_pointeur,_taille) 				G_STMT_START{				\
		if( (_pointeur) == NULL ) { 										\
     		printf("REALLOC pointer NULL :%s : %d\n",__FILE__,__LINE__);		\
		} 																	\
		(_pointeur) = realloc (_pointeur,_taille);							\
		if( (_pointeur) == NULL ) { 										\
     		printf("REALLOC  Failed :%s : %d\n",__FILE__,__LINE__);	   		\
     		exit(EXIT_FAILURE); 											\
		} 																	\
		}G_STMT_END
		

#define MYFREE(x)						G_STMT_START{							\
		if (x!=NULL) 														\
			g_free(x); 														\
		else																\
			printf("MYFREE pointer NULL :%s : %d\n",__FILE__,__LINE__);			\
		x = NULL;  															\ 
		}G_STMT_END
	
		
#define GTKFREEZE(widget)						G_STMT_START{							\
		gtk_widget_freeze_child_notify(GTK_WIDGET(widget));  															\ 
		}G_STMT_END

		
#define GTKTHAW(widget)						G_STMT_START{							\
		gtk_widget_thaw_child_notify(GTK_WIDGET(widget));  															\ 
		}G_STMT_END
		
#endif
