1 /* gAlan - Graphical Audio Language
2 * Copyright (C) 1999 Tony Garnock-Jones
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "generator.h"
39 #include "galan_jack.h"
40 #include "galan_lash.h"
42 //PRIVATE GStaticMutex malloc_mutex = G_STATIC_MUTEX_INIT;
43 PUBLIC GThread
*main_thread
;
45 PUBLIC
char *safe_string_dup(const char *str
) {
51 n
= safe_malloc(strlen(str
) + 1);
56 PUBLIC
void *safe_malloc(size_t size
) {
59 //g_static_mutex_lock( &malloc_mutex );
61 result
= malloc(size
);
63 //printf( "malloc size = %d\n", size );
64 //printf( "malloc\n" );
65 //g_static_mutex_unlock( &malloc_mutex );
69 g_error("Out of memory mallocing %d bytes...", (int) size
);
74 PUBLIC
void *safe_calloc(int nelems
, size_t size
) {
77 //g_static_mutex_lock( &malloc_mutex );
79 result
= calloc(nelems
, size
);
81 //g_static_mutex_unlock( &malloc_mutex );
85 g_error("Out of memory callocing %d bytes...", (int) size
);
90 PUBLIC
void *safe_realloc( gpointer mem
, gsize nbytes
) {
94 //g_static_mutex_lock( &malloc_mutex );
96 result
= realloc(mem
, nbytes
);
98 //g_static_mutex_unlock( &malloc_mutex );
103 PUBLIC
void safe_free( void *ptr
) {
104 //g_static_mutex_lock( &malloc_mutex );
108 //g_static_mutex_unlock( &malloc_mutex );
111 PUBLIC
void lock_malloc_lock( void ) {
112 //g_static_mutex_lock( &malloc_mutex );
115 PUBLIC
void unlock_malloc_lock( void ) {
116 //g_static_mutex_unlock( &malloc_mutex );
119 /* Called by main() in main.c */
120 PUBLIC
int galan_main(int argc
, char *argv
[]) {
122 //GMemVTable vtable = { safe_malloc, safe_realloc, safe_free, NULL, NULL, NULL };
123 //g_mem_set_vtable( &vtable );
128 main_thread
= g_thread_self();
130 gtk_init(&argc
, &argv
);
133 gtk_rc_parse_string( "style \"trans\" { bg_pixmap[NORMAL] = \"<parent>\" } \nwidget \"control_panel.GtkNotebook.GtkScrolledWindow.GtkLayout.*\" style \"trans\" " );
136 init_lash( argc
, argv
);
155 init_generator_thread();
156 init_control_thread();
159 if( ! g_path_is_absolute( argv
[1] ) ) {
160 char *cwd
= g_get_current_dir();
161 char *absname
= g_build_filename( cwd
, argv
[1], NULL
);
162 load_sheet_from_name( absname
);
166 load_sheet_from_name( argv
[1] );
168 Sheet
*s
= create_sheet();
169 s
->control_panel
= control_panel_new( s
->name
, TRUE
, s
);
170 gui_register_sheet( s
);