extern void eo_nvsetbrdbuilder_Delete(EOnvsetBRDbuilder* p) { if(NULL == p) { return; } if(NULL == p->epcfg_vector) { return; } p->brdcfg->epcfg_constvect = NULL; eo_mempool_Delete(eo_mempool_GetHandle(), p->brdcfg); memset(p->brdcfg, 0, sizeof(eOnvset_BRDcfg_t)); eo_vector_Delete(p->epcfg_vector); p->epcfg_vector = NULL; eo_mempool_Delete(eo_mempool_GetHandle(), p); return; }
extern void eo_fifo_Delete(EOfifo * fifo) { if(NULL == fifo) { // invalid fifo return; } if(NULL == fifo->dek) { return; } if(NULL != fifo->mutex) { eov_mutex_Take(fifo->mutex, eok_reltimeINFINITE); } eo_fifo_Clear(fifo, eok_reltimeINFINITE); eo_mempool_Delete(eo_mempool_GetHandle(), fifo->dek); fifo->dek = NULL; if(NULL != fifo->mutex) { //eov_mutex_Release(fifo->mutex); // however, if someone is waiting for this mutex, then there is a crash ... so, maybe better not to release } memset(fifo, 0, sizeof(EOfifo)); eo_mempool_Delete(eo_mempool_GetHandle(), fifo); return; }
static eOresult_t s_eo_nvset_DeinitEPs(EOnvSet* p) { eOnvset_brd_t* theBoard = &p->theboard; uint16_t i = 0; uint16_t endpointsnum = 0; if(NULL == theBoard->theendpoints) { // already deinitted return(eores_OK); } endpointsnum = eo_vector_Size(theBoard->theendpoints); for(i=0; i<endpointsnum; i++) { eOnvset_ep_t **ppep = (eOnvset_ep_t **)eo_vector_At(theBoard->theendpoints, i); eOnvset_ep_t *theEndpoint = *ppep; // now i erase memory associated with this endpoint eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint->epram); // and i dissociates that from from the internals of the eoprot library eoprot_config_endpoint_ram(theBoard->boardnum, theEndpoint->epcfg.endpoint, NULL, 0); // i also de-init the number of entities for that endpoint eoprot_config_endpoint_entities(theBoard->boardnum, theEndpoint->epcfg.endpoint, NULL); // now i delete all data associated to the mutex protection if(NULL != theEndpoint->mtx_endpoint) { eov_mutex_Delete(theEndpoint->mtx_endpoint); } if(NULL != theEndpoint->themtxofthenvs) { uint16_t size = eo_vector_Size(theEndpoint->themtxofthenvs); int j = 0; for(j=0; j<size; j++) { EOVmutexDerived** pmtx = (EOVmutexDerived**)eo_vector_At(theEndpoint->themtxofthenvs, j); eov_mutex_Delete(*pmtx); } eo_vector_Delete(theEndpoint->themtxofthenvs); } // now i erase the memory of the entire eOnvset_ep_t entry eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint); } // so that we dont get in here inside again theBoard->theendpoints = NULL; return(eores_OK); }
extern void eo_rop_Delete(EOrop *p) { if(NULL == p) { return; } if(0 != p->stream.capacity) { eo_mempool_Delete(eo_mempool_GetHandle(), p->stream.data); } memset(p, 0, sizeof(EOrop)); eo_mempool_Delete(eo_mempool_GetHandle(), p); return; }
extern void eov_mutex_hid_Delete(EOVmutex *p) { if(NULL == p) { return; } memset(p, 0, sizeof(EOVmutex)); eo_mempool_Delete(eo_mempool_GetHandle(), p); return; }
extern void eo_receiver_Delete(EOreceiver *p) { if(NULL == p) { return; } if(NULL == p->ropinput) { return; } eo_mempool_Delete(eo_mempool_GetHandle(), p->bufferropframereply); eo_rop_Delete(p->ropreply); eo_rop_Delete(p->ropinput); eo_ropframe_Delete(p->ropframereply); eo_ropframe_Delete(p->ropframeinput); memset(p, 0, sizeof(EOreceiver)); eo_mempool_Delete(eo_mempool_GetHandle(), p); return; }
extern void eo_nvset_Delete(EOnvSet* p) { if(NULL == p) { return; } eo_nvset_DeinitBRD(p); memset(p, 0, sizeof(EOnvSet)); eo_mempool_Delete(eo_mempool_GetHandle(), p); return; }
extern void eo_deque_Delete(EOdeque * deque) { if(NULL == deque) { // invalid deque return; } if(NULL == deque->stored_items) { return; } eo_deque_Clear(deque); memset(deque, 0, sizeof(EOdeque)); eo_mempool_Delete(eo_mempool_GetHandle(), deque); return; }
extern void eo_fifoword_Delete(EOfifoWord *fifoword) { if(NULL == fifoword) { return; } if(NULL == fifoword->fifo) { return; } eo_fifoword_Clear(fifoword, eok_reltimeINFINITE); eo_fifo_Delete(fifoword->fifo); memset(fifoword, 0, sizeof(EOfifoWord)); eo_mempool_Delete(eo_mempool_GetHandle(), fifoword); return; }
extern void eo_confman_Delete(EOconfirmationManager *p) { if(NULL == p) { return; } if(NULL != p->mtx) { eov_mutex_Delete(p->mtx); } if(NULL != p->confrequests) { eo_vector_Delete(p->confrequests); } memset(p, 0, sizeof(EOconfirmationManager)); eo_mempool_Delete(eo_mempool_GetHandle(), p); return; }
extern void eoy_mutex_Delete(EOYmutex *m) { if(NULL == m) { return; } if(NULL == m->acemutex) { return; } //#warning -> marco.accame: must uncomment the following but only after ace_mutex_delete() is implemented //ace_mutex_delete(m->acemutex); eov_mutex_hid_Delete(m->mutex); memset(m, 0, sizeof(EOYmutex)); eo_mempool_Delete(eo_mempool_GetHandle(), m); return; }
extern eOresult_t eo_nvset_LoadEP(EOnvSet* p, eOprot_EPcfg_t *cfgofep, eObool_t initNVs) { eOnvset_brd_t* theBoard = NULL; eOnvBRD_t brd = 0; // local or 0, 1, 2, etc. eOnvset_ep_t *theEndpoint = NULL; uint16_t epnvsnumberof = 0; uint16_t sizeofram =0; if((NULL == p) || (NULL == cfgofep)) { return(eores_NOK_nullpointer); } theBoard = &p->theboard; brd = p->theboard.boardnum; theEndpoint = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(eOnvset_ep_t)); memcpy(&theEndpoint->epcfg, cfgofep, sizeof(eOprot_EPcfg_t)); // ok, now in theEndpoint->epcfg.numberofsentities[] we have some ram. we use it to load the protocol. eoprot_config_endpoint_entities(brd, theEndpoint->epcfg.endpoint, theEndpoint->epcfg.numberofentities); // now it is ok to compute the size of the endpoint using the proper protocol function sizeofram = eoprot_endpoint_sizeof_get(brd, theEndpoint->epcfg.endpoint); // now that i have loaded the number of entities i verify if they are ok by checking the number of variables in the endpoint. epnvsnumberof = eoprot_endpoint_numberofvariables_get(brd, cfgofep->endpoint); if(0 == epnvsnumberof) { //#warning TBD: see how we continue in here .... char str[64] = {0}; snprintf(str, sizeof(str), "EOnvSet: ep %d has 0 nvs", cfgofep->endpoint); eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, str, NULL, &eo_errman_DescrRuntimeErrorLocal); eoprot_config_endpoint_entities(brd, theEndpoint->epcfg.endpoint, NULL); eo_mempool_Delete(eo_mempool_GetHandle(), theEndpoint); return(eores_NOK_generic); } theEndpoint->epnvsnumberof = epnvsnumberof; theEndpoint->initted = eobool_false; theEndpoint->epram = eo_mempool_GetMemory(eo_mempool_GetHandle(), eo_mempool_align_auto, sizeofram, 1); theEndpoint->mtx_endpoint = (eo_nvset_protection_one_per_endpoint == p->protection) ? p->mtxderived_new() : NULL; // now we must load the ram in the endpoint eoprot_config_endpoint_ram(brd, theEndpoint->epcfg.endpoint, theEndpoint->epram, sizeofram); // now add the vector of mtx if needed. if(eo_nvset_protection_one_per_netvar == p->protection) { uint16_t i; theEndpoint->themtxofthenvs = eo_vector_New(sizeof(EOVmutexDerived*), epnvsnumberof, NULL, 0, NULL, NULL); for(i=0; i<epnvsnumberof; i++) { EOVmutexDerived* mtx = p->mtxderived_new(); eo_vector_PushBack(theEndpoint->themtxofthenvs, &mtx); } } // now, i must update the mapping function from ep value to vector of endpoints theBoard->ep2indexlut[theEndpoint->epcfg.endpoint] = eo_vector_Size(theBoard->theendpoints); // and only now i push back the endpoint eo_vector_PushBack(theBoard->theendpoints, &theEndpoint); if(eobool_true == initNVs) { s_eo_nvset_NVsOfEP_Initialise(p, theEndpoint, theEndpoint->epcfg.endpoint); } return(eores_OK); }