Exemple #1
0
void cmmjl_free(void *x){
	// An instance has been deleted, so we need to go through and free all 
	// of the data we allocated for it.

	t_cmmjl_obj *o = cmmjl_obj_get(x);
	int i;
	if(o->osc_address_methods){
		linklist_clear(o->osc_address_methods);
		free(o->osc_address_methods);
	}
	cmmjl_obj_instance_mark_free(x, o->instance);
	if(o->osc_scheduler){
		cmmjl_osc_schedule_free(o->osc_scheduler);
		free(o->osc_scheduler);
	}
	if(o->entrance_count_tab){
		hashtab_clear(o->entrance_count_tab);
		free(o->entrance_count_tab);
	}
	hashtab_delete(_cmmjl_obj_tab, x);
	if(hashtab_getsize(_cmmjl_obj_tab) == 0){
		free(_cmmjl_obj_tab);
		hashtab_clear(_cmmjl_instance_count);
		free(_cmmjl_instance_count);
	}
}
Exemple #2
0
t_max_err dbviewer_notify(t_dbviewer *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{	
	if(sender == x->d_view){
		if(msg == ps_dbview_update){
			dbviewer_bang(x);
		}
		else if(msg == ps_dbview_query_changed){	// dump all of the columns
			t_object	*column = NULL;
			t_symbol	**column_names = NULL;
			long		numcolumns = 0;
			long		i;
			
			hashtab_getkeys(x->d_columns, &numcolumns, &column_names);
			if(column_names){
				for(i=0; i<numcolumns; i++){
					column = jdataview_getnamedcolumn(x->d_dataview, column_names[i]);
					if(column)
						jdataview_deletecolumn(x->d_dataview, column);
				}		
				sysmem_freeptr(column_names);
			}
			hashtab_clear(x->d_columns);
		}
		else if(msg == _sym_free){
			object_detach_byptr((t_object *)x, x->d_view);
			x->d_view = NULL;		
		}
	}
	return jbox_notify((t_jbox*)x, s, msg, sender, data);
}
Exemple #3
0
static struct scope* scope_done(struct scope *s)
{
	struct scope* parent = s->parent;
	/* TODO: have a hashtab_destroy */
	hashtab_clear(&s->id_map);
	free(s->id_map.htable);
	free(s);
	return parent;
}
void howbigisyourp_bang(t_howbigisyourp *x)
{
	t_object *jp;
	t_max_err err;
	long result = 0;

	hashtab_clear(x->hash);

	err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);
	if (err != MAX_ERR_NONE)
		return;

	// iterate through every objects
	if (jp)
		object_method(jp, gensym("iterate"), (method)howbigisyourp_callback, x, PI_DEEP | PI_WANTBOX, &result);
}
Exemple #5
0
int cc_doload(t_cc *x, t_symbol *lib){
	while(x->ok_to_compile == 0){}
	x->compiling = 1;
	int ret = 0;

	t_symbol *dfile_sym = lib;
	if(!dfile_sym){
		if(x->dfile_fullpath){
			dfile_sym = gensym(x->dfile_fullpath);
		}else{
			goto out;
		}
	}

	char dfile[MAX_PATH_CHARS];
	strcpy(dfile, dfile_sym->s_name);
	//char *ptr = dfile->s_name;
	//if(*ptr != '/'){
	short outvol;
	long outtype;
	if(locatefile_extended(dfile, &outvol, &outtype, NULL, 0)){
		error("cc: couldn't locate %s", dfile);
		ret = 1;
		goto out;
	}else{
		char buf[MAX_PATH_CHARS];
		path_topathname(outvol, dfile, buf);
		char *ptr = buf;
		while(*ptr++ != ':'){}
		dfile_sym = gensym(ptr);
		strcpy(dfile, dfile_sym->s_name);
	}

	x->handle = dlopen(dfile, RTLD_NOW);
	if(!x->handle){
		error("cc: %s", dlerror());
		ret = 1;
		goto out;
	}

	// read the symbols from the dylib
	hashtab_clear(x->ht);
	char *err;
	char st[MAX_PATH_CHARS];
	sprintf(st, "%s/.%s", x->build_path, x->basename);

	char compbuf[1024];
	sprintf(compbuf, "nm %s | awk '$2 ~ /T/ {print $3}' > %s", dfile, st);
	if(system(compbuf)){
		error("cc: couldn't parse symbol table");
		ret = 1;
		goto out;
	}

	FILE *fp = fopen(st, "r");
	if(!fp){
		error("cc: couldn't read symbol table");
		ret = 1;
		goto out;
	}

	char buf[LINE_MAX];
	int i = 0;
	while(fgets(buf, LINE_MAX, fp)){
		buf[strlen(buf) - 1] = '\0'; // get rid of the newline char
		//ccmethod f = (ccmethod)dlsym(x->handle, buf + 1);
		long f = (long)dlsym(x->handle, buf + 1);
		if((err = dlerror()) == NULL){
			x->function_names[i] = gensym(buf + 1); // skip over the leading underscore
			hashtab_store(x->ht, x->function_names[i], (t_object *)f);
#if defined(CC_JBOX)
			if(!strcmp(buf + 1, "my_paint")){
				x->user_paint = (ccpaint_method)f;
			}
#endif
			post("%s", buf + 1);
		}
	}
	fclose(fp);
	remove(st);

	void (*f)(t_object *, char *);
	hashtab_lookup(x->ht, gensym("my_new"), (t_object **)&f);
	if(f){
		f((t_object *)x, x->user_obj);
	}
 out:
	x->compiling = 0;
#if defined(CC_JBOX)
	jbox_redraw((t_jbox *)x);
#endif
	return ret;
}
void howbigisyourp_free(t_howbigisyourp *x)
{
	hashtab_clear(x->hash);
}