void hammerfile_free(t_hammerfile *f) { t_hammerfile *prev, *next; hammereditor_close(f, 0); if (f->f_embedfn) /* just in case of missing 'restore' */ hammerembed_gc(f->f_master, ps__C, 0); if (f->f_savepanel) { pd_unbind((t_pd *)f->f_savepanel, f->f_savepanel->f_bindname); pd_free((t_pd *)f->f_savepanel); } if (f->f_bindname) pd_unbind((t_pd *)f, f->f_bindname); if (f->f_panelclock) clock_free(f->f_panelclock); if (f->f_editorclock) clock_free(f->f_editorclock); for (prev = 0, next = hammerfile_proxies; next; prev = next, next = next->f_next) if (next == f) break; if (prev) prev->f_next = f->f_next; else if (f == hammerfile_proxies) hammerfile_proxies = f->f_next; pd_free((t_pd *)f); }
void pd_string_free(t_pdstring *str) { if (!str) return; if (str->strData) { pd_free(str->strData); } pd_free(str); }
void FUNCTION_ATTRIBUTE pando_buffer_delete(struct pando_buffer *pdbuf) { if (pdbuf == NULL) { return; } if (pdbuf->buffer != NULL) { pd_free(pdbuf->buffer); } pd_free(pdbuf); }
void FUNCTION_ATTRIBUTE delete_device_package(struct sub_device_buffer *device_buffer) { if (device_buffer != NULL) { if (device_buffer->buffer != NULL) { pd_free(device_buffer->buffer); device_buffer->buffer = NULL; } } pd_free(device_buffer); device_buffer = NULL; }
static void *cycle_new(t_symbol *s, int ac, t_atom *av) { t_cycle *x = (t_cycle *)pd_new(cycle_class); int i = (ac && av->a_type == A_FLOAT ? 1 : 0); int tabsize = CYCLE_TABSIZE; x->x_costable = sic_makecostable(&tabsize); if (tabsize != CYCLE_TABSIZE) { loudbug_bug("cycle_new"); pd_free((t_pd *)x); return (0); } if (ac && av->a_type == A_FLOAT) { sic_inlet((t_sic *)x, 0, 0, 0, ac, av); ac--, av++; } sic_newinlet((t_sic *)x, 0); outlet_new((t_object *)x, &s_signal); x->x_offset = 0; if (ac && av->a_type == A_SYMBOL) { x->x_name = av->a_w.w_symbol; ac--, av++; if (ac && av->a_type == A_FLOAT) if ((x->x_offset = (int)av->a_w.w_float) < 0) x->x_offset = 0; } else x->x_name = 0; x->x_table = 0; x->x_phase = 0.; x->x_conv = 0.; return (x); }
static void multireceive_free(t_multireceive *x) { multireceive_clear(x); pd_free((t_pd *)x->x_proxy); outlet_free(x->x_out); x->x_out=NULL; }
/* adapted pd_unbind() from m_pd.c */ void dict_unbind(t_dict *x, t_pd *obj, t_symbol *s) { #ifdef DICT_DEBUG post("unbind %x from \"%s\" at %x", (int)obj, s->s_name, (int)s); #endif if (s->s_thing == obj) s->s_thing = 0; else if (s->s_thing && *s->s_thing == x->d_bindlist_class) { /* bindlists always have at least two elements... if the number goes down to one, get rid of the bindlist and bind the symbol straight to the remaining element. */ t_dict_bindlist *b = (t_dict_bindlist *)s->s_thing; t_dict_bindelem *e, *e2; if ((e = b->b_list)->e_who == obj) { b->b_list = e->e_next; freebytes(e, sizeof(t_dict_bindelem)); } else for (e = b->b_list; e2 = e->e_next; e = e2) if (e2->e_who == obj) { e->e_next = e2->e_next; freebytes(e2, sizeof(t_dict_bindelem)); break; } if (!b->b_list->e_next) { s->s_thing = b->b_list->e_who; freebytes(b->b_list, sizeof(t_dict_bindelem)); pd_free(&b->b_pd); } } else pd_error(obj, "%s: couldn't unbind", s->s_name); }
packet_data* pd_alloc(uint16_t size, uint16_t block_size) { packet_data* pd = NULL; packet_data* next = NULL; while(size) { uint16_t alloc_size = size > block_size ? block_size : size; if (next == NULL) { pd = bget(align_size(sizeof(packet_data) + alloc_size)); next = pd; } else { next->next = bget(align_size(sizeof(packet_data) + alloc_size)); next = next->next; } if (next == NULL) { pd_free(pd); return NULL; } pd->data = (uint8_t*)pd + sizeof(packet_data); pd->next = NULL; pd->size = alloc_size; pd->total_size = size; pd->refs_count = 1; size -= alloc_size; } return pd; }
static void bindlist_cleanup(t_bindlist *x) { //fprintf(stderr,"bindlist_cleanup\n"); t_bindelem *e, *e2; if (x->b_list->e_who == NULL) { e = x->b_list; x->b_list = e->e_next; freebytes(e, sizeof(t_bindelem)); //fprintf(stderr,"success B1a\n"); } for (e = x->b_list; e2 = e->e_next; e = e2) if (e2->e_who == NULL) { e->e_next = e2->e_next; freebytes(e2, sizeof(t_bindelem)); //fprintf(stderr,"success B1b\n"); break; } if (!x->b_list->e_next) { freebytes(x->b_list, sizeof(t_bindelem)); pd_free(&x->b_pd); //fprintf(stderr,"success B2\n"); } }
struct pt_directive *pd_alloc(size_t n) { struct pt_directive *pd; pd = calloc(1, sizeof(*pd)); if (!pd) return NULL; pd->name = malloc(n); if (!pd->name) goto error; pd->payload = malloc(n); if (!pd->payload) goto error; pd->nlen = n; pd->plen = n; return pd; error: pd_free(pd); return NULL; }
/* malloc a new block to save old buffer and new property, and update the package length */ int FUNCTION_ATTRIBUTE add_next_property(struct sub_device_buffer *data_package, uint16_t property_num, struct TLVs *next_data_params) { uint8_t *old_buffer = NULL; uint8_t *position = NULL; uint16_t old_len = 0; uint16_t subdevice_id; if (data_package == NULL) { return -1; } old_buffer = data_package->buffer; old_len = data_package->buffer_length; /* append payload length */ data_package->buffer_length += (sizeof(struct pando_property) + current_tlv_block_size - sizeof(struct TLVs)); data_package->buffer = (uint8_t *)pd_malloc(data_package->buffer_length); pd_memset(data_package->buffer, 0, data_package->buffer_length); /* copy old content and new property */ position = copy_return_next(data_package->buffer, old_buffer, old_len); subdevice_id = 0; position = copy_return_next(position, &subdevice_id, sizeof(subdevice_id)); property_num = host16_to_net(property_num); position = copy_return_next(position, &property_num, sizeof(property_num)); pd_memcpy(position, next_data_params, current_tlv_block_size); pd_free(old_buffer); return 0; }
void pd_unbind(t_pd *x, t_symbol *s) { if (s->s_thing == x) s->s_thing = 0; else if (s->s_thing && *s->s_thing == bindlist_class) { /* bindlists always have at least two elements... if the number goes down to one, get rid of the bindlist and bind the symbol straight to the remaining element. */ t_bindlist *b = (t_bindlist *)s->s_thing; t_bindelem *e, *e2; if ((e = b->b_list)->e_who == x) { b->b_list = e->e_next; freebytes(e, sizeof(t_bindelem)); } else for (e = b->b_list; e2 = e->e_next; e = e2) if (e2->e_who == x) { e->e_next = e2->e_next; freebytes(e2, sizeof(t_bindelem)); break; } if (!b->b_list->e_next) { s->s_thing = b->b_list->e_who; freebytes(b->b_list, sizeof(t_bindelem)); pd_free(&b->b_pd); } } else pd_error(x, "%s: couldn't unbind", s->s_name); }
void FUNCTION_ATTRIBUTE delete_pando_objects_iterator(pando_objects_iterator* it) { if(it) { pd_free(it); } }
void delete_params_block(struct TLVs *params_block) { if (params_block != NULL) { pd_free(params_block); params_block = NULL; } }
static void prepender_free(t_prepender *x) { if(!x->x_ninstance) return; for(int i = 0; i < x->x_ninstance; i++) { pd_free((t_pd *)x->x_proxies[i]); } freebytes(x->x_proxies, sizeof(t_proxy *) * x->x_ninstance); }
void FUNCTION_ATTRIBUTE delete_params_block(struct TLVs *params_block) { if (params_block != NULL) { pd_free(params_block); params_block = NULL; } }
/*! This virtual function is called before the destructor. We do this because here we can still call virtual methods. */ void flext_base::Exit() { #if FLEXT_SYS == FLEXT_SYS_MAX // according to David Z. one should do that first... if(NeedDSP()) dsp_free(thisHdr()); #endif #if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT) // attribute editor window may still be open -> close it gfxstub_deleteforkey(thisHdr()); #endif #ifdef FLEXT_THREADS StopThreads(); #endif // send remaining pending messages for this object QFlush(this); // delete message lists if(bindhead) delete bindhead; // ATTENTION: the object must free all memory associated to bindings itself if(methhead) delete methhead; if(attrhead) delete attrhead; if(attrdata) delete attrdata; #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX if(outlets) delete[] outlets; if(inlets) { FLEXT_ASSERT(incnt > 1); for(int ix = 1; ix < incnt; ++ix) if(inlets[ix-1]) { // release proxy object #if FLEXT_SYS == FLEXT_SYS_PD pd_free(&inlets[ix-1]->obj.ob_pd); #elif FLEXT_SYS == FLEXT_SYS_MAX freeobject((object *)inlets[ix-1]); #endif } delete[] inlets; } #endif #if FLEXT_SYS == FLEXT_SYS_MAX if(indesc) { for(int i = 0; i < incnt; ++i) if(indesc[i]) delete[] indesc[i]; delete[] indesc; } if(outdesc) { for(int i = 0; i < outcnt; ++i) if(outdesc[i]) delete[] outdesc[i]; delete[] outdesc; } #endif flext_obj::Exit(); }
void lp_free(laser_packet* lp) { if (lp == NULL) { return; } pd_free(lp->data); brel(lp); }
/* the GUI calls this when it disappears. (If there's any chance the GUI will fail to do this, the "target", when it signs off, should specify a timeout after which the guiconnect will disappear.) */ static void guiconnect_signoff(t_guiconnect *x) { if (!x->x_who) pd_free(&x->x_obj.ob_pd); else { pd_unbind(&x->x_obj.ob_pd, x->x_sym); x->x_sym = 0; } }
void number_release(t_symbol *s) { t_number *num = (t_number *)pd_findbyclass(s,number_class); if (num) { if (!--num->o_refcount) { pd_unbind(&num->o_pd, s); pd_free(&num->o_pd); } } else bug("value_release"); }
/****************************************************************************** * FunctionName : zero_device_data_process. * Description : process the received data of zero device(zero device is the gateway itself). * Parameters : uint. * Returns : none. *******************************************************************************/ static void FUNCTION_ATTRIBUTE zero_device_data_process(uint8_t * buffer, uint16_t length) { struct pando_command cmd_body; uint16_t type = 0; uint16_t len = 0; struct sub_device_buffer * device_buffer = (struct sub_device_buffer *)pd_malloc(sizeof(struct sub_device_buffer)); if(device_buffer == NULL) { pd_printf("%s:malloc error!\n", __func__); return; } device_buffer->buffer = (uint8_t*)pd_malloc(length); if(device_buffer->buffer == NULL) { pd_printf("%s:malloc error!\n", __func__); pd_free(device_buffer); return; } pd_memcpy(device_buffer->buffer, buffer, length); device_buffer->buffer_length = length; struct TLVs *cmd_param = get_sub_device_command(device_buffer, &cmd_body); if(COMMON_COMMAND_SYN_TIME == cmd_body.command_num ) { pd_printf("PANDO: synchronize time\n"); uint64_t time = get_next_uint64(cmd_param); show_package((uint8_t*)(&time), sizeof(time)); // pando_set_system_time(time); } if( device_buffer->buffer != NULL) { pd_free( device_buffer->buffer); device_buffer->buffer = NULL; } if(device_buffer != NULL) { pd_free(device_buffer); device_buffer = NULL; } }
/* Deallocates the memory used by @p, closes all files, clears and * zeroes the fields. */ static void p_free(struct parser *p) { if (!p) return; yasm_free(p->y); pd_free(p->pd); free(p->ptfilename); free(p); }
/* not used (LATER find a gc scheme) */ static void patchstorage_removevalue( t_patchstorage *ps, t_patchvalue *prv, t_patchvalue *pv, int force) { if (force || pv->pv_refcount < 1) { if (prv) prv->pv_next = pv->pv_next; else ps->ps_values = pv->pv_next; pd_free((t_pd *)pv); } }
int test_pd(void) { test_start("page directory"); seL4_CPtr p[PD_MAX]; for (int i = 0; i < PD_MAX; i++) { p[i] = pd_assign(&procServ.PDList).kpdObject; test_assert(p[i] != 0); } for (int i = 0; i < PD_MAX; i++) { pd_free(&procServ.PDList, p[i]); } for (int i = 0; i < 2; i++) { p[i] = pd_assign(&procServ.PDList).kpdObject; test_assert(p[i] != 0); } for (int i = 0; i < 2; i++) { pd_free(&procServ.PDList, p[i]); } return test_success(); }
/* only for debugging (never call, unless certain that nobody references wt) */ static void widgettype_free(t_masterwidget *mw, t_widgettype *wt) { loudbug_startpost("widgettype free... "); if (wt->wt_requirements) freebytes(wt->wt_requirements, strlen(wt->wt_requirements) + 1); dict_unbind(mw->mw_typemap, (t_pd *)wt, wt->wt_typekey); props_freeall(wt->wt_options); scriptlet_free(wt->wt_auxscript); widgethandlers_free(wt->wt_scripts); pd_free((t_pd *)wt); loudbug_post("done"); }
void FUNCTION_ATTRIBUTE MQTT_Disconnect(MQTT_Client *mqttClient) { if(mqttClient->pCon) { INFO("Free memory\r\n"); net_tcp_disconnect(mqttClient->pCon); pd_free(mqttClient->pCon); mqttClient->pCon = NULL; } pando_timer_stop(&(mqttClient->mqttTimer)); }
static void append_free(t_append *x) { if (x->x_messbuf != x->x_messini) freebytes(x->x_messbuf, x->x_size * sizeof(*x->x_messbuf)); if (x->x_auxbuf) { loudbug_bug("append_free"); /* LATER rethink */ freebytes(x->x_auxbuf, x->x_auxsize * sizeof(*x->x_auxbuf)); } if (x->x_proxy) pd_free(x->x_proxy); }
/* release a variable. This only frees the "vcommon" resource when the last interested party releases it. */ void value_release(t_symbol *s) { t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class); if (c) { if (!--c->c_refcount) { pd_unbind(&c->c_pd, s); pd_free(&c->c_pd); } } else bug("value_release"); }
static void scope_free(t_scope *x) { if (x->x_clock) clock_free(x->x_clock); if (x->x_xbuffer != x->x_xbufini) freebytes(x->x_xbuffer, x->x_allocsize * sizeof(*x->x_xbuffer)); if (x->x_ybuffer != x->x_ybufini) freebytes(x->x_ybuffer, x->x_allocsize * sizeof(*x->x_ybuffer)); if (x->x_handle) { pd_unbind(x->x_handle, ((t_scopehandle *)x->x_handle)->h_bindsym); pd_free(x->x_handle); } }
/* the target calls this to disconnect. If the gui has "signed off" we're ready to delete the object; otherwise we wait either for signoff or for a timeout. */ void guiconnect_notarget(t_guiconnect *x, double timedelay) { if (!x->x_sym) pd_free(&x->x_obj.ob_pd); else { x->x_who = 0; if (timedelay > 0) { x->x_clock = clock_new(x, (t_method)guiconnect_tick); clock_delay(x->x_clock, timedelay); } } }