void DeleteAmaclList(OicSecAmacl_t* amacl)
{
    if (amacl)
    {
        OicSecAmacl_t *amaclTmp1 = NULL, *amaclTmp2 = NULL;
        LL_FOREACH_SAFE(amacl, amaclTmp1, amaclTmp2)
        {
            unsigned int i = 0;

            LL_DELETE(amacl, amaclTmp1);

            // Clean Resources
            for (i = 0; i < amaclTmp1->resourcesLen; i++)
            {
                OICFree(amaclTmp1->resources[i]);
            }
            OICFree(amaclTmp1->resources);

            // Clean Amss
            OICFree(amaclTmp1->amss);

            // Clean Owners
            OICFree(amaclTmp1->owners);

            // Clean Amacl node itself
            OICFree(amaclTmp1);
        }
    }
Esempio n. 2
0
Mavlink::~Mavlink()
{
	perf_free(_loop_perf);
	perf_free(_txerr_perf);

	if (_task_running) {
		/* task wakes up every 10ms or so at the longest */
		_task_should_exit = true;

		/* wait for a second for the task to quit at our request */
		unsigned i = 0;

		do {
			/* wait 20ms */
			usleep(20000);

			/* if we have given up, kill it */
			if (++i > 50) {
				//TODO store main task handle in Mavlink instance to allow killing task
				//task_delete(_mavlink_task);
				break;
			}
		} while (_task_running);
	}

	if (_mavlink_instances) {
		LL_DELETE(_mavlink_instances, this);
	}
}
Esempio n. 3
0
TWResultCode TWDeleteTWSock(TWSock * sock)
{
    if(!sock)
    {
        return TW_RESULT_ERROR_INVALID_PARAMS;
    }
    TWSock * out = NULL;
    TWSock * tmp = NULL;
    LL_FOREACH_SAFE(g_twSockList, out, tmp)
    {
        if(out == sock)
        {
            LL_DELETE(g_twSockList, out);
        }
    }

    OICFree(sock->buffer);
    OICFree(sock->eui);
    TWFreeQueue(sock->plugin);

    int mutexRet = pthread_mutex_destroy(&(sock->mutex));
    if(mutexRet != 0)
    {
        OC_LOG_V(ERROR, TAG, "Failed to destroy mutex. Error: %d", mutexRet);
        return TW_RESULT_ERROR;
    }
    TWResultCode result = TWCloseTWSock(sock);

    return result;
}
Esempio n. 4
0
void profiler_start(void)
{
    profiler_block_t *b, *tmp;
    LL_FOREACH_SAFE(g_blocks, b, tmp) {
        b->count = b->tot_time = b->self_time = b->depth = 0;
        LL_DELETE(g_blocks, b);
    }
Esempio n. 5
0
/**
 * Invoke all pending actions prior to specified timestamp
 */
void EventQueue::executeAll(uint64_t now) {
    scheduling_s * current, *tmp;

    scheduling_s * executionList = NULL;

    int counter = 0;

    // we need safe iteration because we are removing elements inside the loop
    LL_FOREACH_SAFE(head, current, tmp)
    {
        if (++counter > QUEUE_LENGTH_LIMIT) {
            firmwareError("Is this list looped?");
            return;
        }
        if (current->momentUs <= now) {
            LL_DELETE(head, current);
            LL_PREPEND(executionList, current);
        }
    }

    /*
     * we need safe iteration here because 'callback' might change change 'current->next'
     * while re-inserting it into the queue from within the callback
     */
    LL_FOREACH_SAFE(executionList, current, tmp)
    current->callback(current->param);
}
Esempio n. 6
0
void lowlevel_scan_free()
{
	if (!devinfo_list)
		return;
	
	struct lowlevel_device_info *info, *tmp;
	struct lowlevel_device_info *info2, *tmp2;
	
	LL_FOREACH_SAFE(devinfo_list, info, tmp)
	{
		LL_DELETE(devinfo_list, info);
		LL_FOREACH_SAFE2(info, info2, tmp2, same_devid_next)
		{
			LL_DELETE(info, info2);
			lowlevel_devinfo_free(info2);
		}
Esempio n. 7
0
ControlledLeds destroyControlledLeds(ControlledLeds leds) {
    if (IsValid(leds)) {
        LL_DELETE(controlled_leds, LEDS);
        cleanUnderlyingLeds(leds);
        free(LEDS);
    }
    return Invalid(ControlledLeds);
}
Esempio n. 8
0
void clear_list(struct fw_rule_node* list) {
	
	struct fw_rule_node* curr;
	LL_FOREACH(list, curr) {
		LL_DELETE(list, curr);	
		free(curr->rule.name);
		free(curr);
	}	
Esempio n. 9
0
void gnrc_netreg_unregister(gnrc_nettype_t type, gnrc_netreg_entry_t *entry)
{
    if (_INVALID_TYPE(type)) {
        return;
    }

    LL_DELETE(netreg[type], entry);
}
Esempio n. 10
0
static void reduceRefcount(LedList element) {
    if (element->references > 0)
        element->references--;
    if (element->references == 0) {
        LL_DELETE(underlying_leds, element);
        free(element);
    }
}
Esempio n. 11
0
static void finalizeObject(Env* env, Object* obj) {
//    TRACEF("finalizeObject: %p (%s)\n", obj, obj->clazz->name);

    rvmLockMutex(&referentsLock);
    void* key = (void*) GC_HIDE_POINTER(obj);
    ReferentEntry* referentEntry;
    HASH_FIND_PTR(referents, &key, referentEntry);

    assert(referentEntry != NULL);

    if (referentEntry->references == NULL) {
        // The object is not referenced by any type of reference and can never be resurrected.
        HASH_DEL(referents, referentEntry);
        rvmUnlockMutex(&referentsLock);
        return;
    }

    Object* softReferences = NULL;
    Object* weakReferences = NULL;
    Object* finalizerReferences = NULL;
    Object* phantomReferences = NULL;
    Object* clearedReferences = NULL;

    ReferenceList* refNode;
    while (referentEntry->references != NULL) {
        refNode = referentEntry->references;
        LL_DELETE(referentEntry->references, refNode);
        Object** list = NULL;
        Object* reference = refNode->reference;
        if (rvmIsSubClass(java_lang_ref_SoftReference, reference->clazz)) {
            list = &softReferences;
        } else if (rvmIsSubClass(java_lang_ref_WeakReference, reference->clazz)) {
            list = &weakReferences;
        } else if (rvmIsSubClass(java_lang_ref_FinalizerReference, reference->clazz)) {
            list = &finalizerReferences;
        } else if (rvmIsSubClass(java_lang_ref_PhantomReference, reference->clazz)) {
            list = &phantomReferences;
        }
        enqueuePendingReference(env, reference, list);
    }
    assert(referentEntry->references == NULL);

    clearAndEnqueueReferences(env, &softReferences, &clearedReferences);
    clearAndEnqueueReferences(env, &weakReferences, &clearedReferences);
    enqueueFinalizerReferences(env, &finalizerReferences, &clearedReferences);
    clearAndEnqueueReferences(env, &phantomReferences, &clearedReferences);

    // Reregister for finalization. If no new references have been added to the list of references for the referent the
    // next time it gets finalized we know it will never be resurrected.
    GC_REGISTER_FINALIZER_NO_ORDER(obj, _finalizeObject, NULL, NULL, NULL);

    rvmUnlockMutex(&referentsLock);

    if (clearedReferences != NULL) {
        rvmCallVoidClassMethod(env, java_lang_ref_ReferenceQueue, java_lang_ref_ReferenceQueue_add, clearedReferences);
        assert(rvmExceptionOccurred(env) == NULL);
    }
}
Esempio n. 12
0
static void close_modules(module *list) {
	module *m,*mt;

	LL_FOREACH_SAFE(list,m,mt) {
		LL_DELETE(list,m);
		if (m->destroy != NULL) m->destroy();
		dlclose(m->handle);
		free(m);
	}
Esempio n. 13
0
void free_pubsub_urls()
{
    struct pubsub_url *ps_url, *tmp;
    
    LL_FOREACH_SAFE(pubsub_urls, ps_url, tmp) {
        LL_DELETE(pubsub_urls, ps_url);
        free(ps_url->address);
        free(ps_url);
    }
Esempio n. 14
0
/* Clear rules loaded into memory */
void clear_rules()
{
    rule * elt, *tmp;
    /* delete each elemen using the safe iterator */
    LL_FOREACH_SAFE(rules,elt,tmp) {
      LL_DELETE(rules,elt);
      free(elt->host);
      free(elt);
    }
Esempio n. 15
0
File: ps2.c Progetto: cmsd2/ChrisOS
struct ps2_async_command * ps2_command_alloc() {
    struct ps2_async_command * cmd;
    if(_ps2_free_commands) {
        cmd = _ps2_free_commands;
        LL_DELETE(_ps2_free_commands, cmd);
    } else {
        cmd = (struct ps2_async_command *)kmalloc(sizeof(struct ps2_async_command));
    }
    return cmd;
}
Esempio n. 16
0
int coap_remove_async(coap_context_t *context, coap_tid_t id, coap_async_state_t **s)
{
    coap_async_state_t *tmp = coap_find_async(context, id);

    if (tmp)
        LL_DELETE(context->async_state, tmp);

    *s = tmp;
    return tmp != NULL;
}
Esempio n. 17
0
/**
 * Delete a server response from the server response list
 *
 * @param serverResponse - server response to delete
 */
static void DeleteServerResponse(OCServerResponse * serverResponse)
{
    if(serverResponse)
    {
        LL_DELETE(serverResponseList, serverResponse);
        OCPayloadDestroy(serverResponse->payload);
        OICFree(serverResponse);
        OIC_LOG(INFO, TAG, "Server Response Removed!!");
    }
}
Esempio n. 18
0
/**
 * Delete a server request from the server request list
 *
 * @param serverRequest - server request to delete
 */
static void DeleteServerRequest(OCServerRequest * serverRequest)
{
    if(serverRequest)
    {
        LL_DELETE(serverRequestList, serverRequest);
        OICFree(serverRequest->requestToken);
        OICFree(serverRequest);
        serverRequest = NULL;
        OIC_LOG(INFO, TAG, "Server Request Removed!!");
    }
}
Esempio n. 19
0
void DeleteCredList(OicSecCred_t* cred)
{
    if (cred)
    {
        OicSecCred_t *credTmp1 = NULL, *credTmp2 = NULL;
        LL_FOREACH_SAFE(cred, credTmp1, credTmp2)
        {
            LL_DELETE(cred, credTmp1);
            FreeCred(credTmp1);
        }
    }
Esempio n. 20
0
void PDMDestoryOicUuidLinkList(OCUuidList_t* ptr)
{
    if(ptr)
    {
        OCUuidList_t *tmp1 = NULL,*tmp2=NULL;
        LL_FOREACH_SAFE(ptr, tmp1, tmp2)
        {
            LL_DELETE(ptr, tmp1);
            OICFree(tmp1);
        }
    }
Esempio n. 21
0
int main() {
    int i;
    el els[10], *e, *tmp, *tmp2;
    for(i=0;i<10;i++) els[i].id='a'+i;

    /* test LL macros */
    printf("LL macros\n");
    LL_APPEND(head,&els[0]);
    LL_APPEND(head,&els[1]);
    LL_APPEND(head,&els[2]);
    LL_FOREACH(head,e)
        printf("%c ", e->id);
    printf("\n");
    LL_SEARCH_SCALAR(head, e, id, 'b');
    if (e) printf("search scalar found b\n");
    LL_SEARCH(head, e, &els[0], eltcmp);
    if (e) printf("search found %c\n",e->id);
    LL_FOREACH_SAFE(head,e,tmp) LL_DELETE(head,e);

    printf("\n");

    /* test DL macros */
    printf("DL macros\n");
    DL_APPEND(head,&els[0]);
    DL_APPEND(head,&els[1]);
    DL_APPEND(head,&els[2]);
    DL_FOREACH(head,e)
        printf("%c ", e->id);
    printf("\n");
    DL_SEARCH_SCALAR(head, e, id, 'b');
    if (e) printf("search scalar found b\n");
    DL_SEARCH(head, e, &els[0], eltcmp);
    if (e) printf("search found %c\n",e->id);
    DL_FOREACH_SAFE(head,e,tmp) DL_DELETE(head,e);
    printf("\n");

    /* test CDL macros */
    printf("CDL macros\n");
    CDL_PREPEND(head,&els[0]);
    CDL_PREPEND(head,&els[1]);
    CDL_PREPEND(head,&els[2]);
    CDL_FOREACH(head,e)
        printf("%c ", e->id);
    printf("\n");
    CDL_SEARCH_SCALAR(head, e, id, 'b');
    if (e) printf("search scalar found b\n");
    CDL_SEARCH(head, e, &els[0], eltcmp);
    if (e) printf("search found %c\n",e->id);
    CDL_FOREACH_SAFE(head,e,tmp,tmp2) CDL_DELETE(head,e);


    return 0;
}
Esempio n. 22
0
void DeleteACLList(OicSecAcl_t* acl)
{
    if (acl)
    {
        OicSecAcl_t *aclTmp1 = NULL;
        OicSecAcl_t *aclTmp2 = NULL;
        LL_FOREACH_SAFE(acl, aclTmp1, aclTmp2)
        {
            LL_DELETE(acl, aclTmp1);
            FreeACE(aclTmp1);
        }
    }
Esempio n. 23
0
	LL_FOREACH_SAFE(iHead, current, tmp)
	{
		if (current->sparkPosition.eventIndex == eventIndex) {
			// time to fire a spark which was scheduled previously
			LL_DELETE(iHead, current);

			scheduling_s * sDown = &current->signalTimerDown;

			float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * current->sparkPosition.angleOffset;
			scheduleTask("spark 2down", sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnPinLow, current->output);
		}
	}
Esempio n. 24
0
_cl_command_node* pocl_mem_manager_new_command ()
{
  _cl_command_node *cmd = NULL;
  POCL_LOCK (mm->cmd_lock);
  if (cmd = mm->cmd_list)
    LL_DELETE (mm->cmd_list, cmd);
  POCL_UNLOCK (mm->cmd_lock);
  
  if (cmd)
    return cmd;
  
  return calloc (1, sizeof (_cl_command_node));
}
Esempio n. 25
0
int
Mavlink::configure_stream(const char *stream_name, const float rate)
{
	/* calculate interval in us, 0 means disabled stream */
	unsigned int interval = (rate > 0.0f) ? (1000000.0f / rate) : 0;

	/* search if stream exists */
	MavlinkStream *stream;
	LL_FOREACH(_streams, stream) {
		if (strcmp(stream_name, stream->get_name()) == 0) {
			if (interval > 0) {
				/* set new interval */
				stream->set_interval(interval);

			} else {
				/* delete stream */
				LL_DELETE(_streams, stream);
				delete stream;
				warnx("deleted stream %s", stream->get_name());
			}

			return OK;
		}
	}

	if (interval == 0) {
		/* stream was not active and is requested to be disabled, do nothing */
		return OK;
	}

	/* search for stream with specified name in supported streams list */
	for (unsigned int i = 0; streams_list[i] != nullptr; i++) {

		if (strcmp(stream_name, streams_list[i]->get_name()) == 0) {
			/* create new instance */
			stream = streams_list[i]->new_instance();
			stream->set_channel(get_channel());
			stream->set_interval(interval);
			stream->subscribe(this);
			LL_APPEND(_streams, stream);

			return OK;
		}
	}

	/* if we reach here, the stream list does not contain the stream */
	warnx("stream %s not found", stream_name);

	return ERROR;
}
Esempio n. 26
0
_cl_command_node* pocl_mem_manager_new_command ()
{
  _cl_command_node *cmd = NULL;
  POCL_LOCK (mm->cmd_lock);
  if ((cmd = mm->cmd_list))
    LL_DELETE (mm->cmd_list, cmd);
  POCL_UNLOCK (mm->cmd_lock);
  
  if (cmd)
    {
      memset (cmd, 0, sizeof (struct _cl_command_node));
      return cmd;
    }
  return (_cl_command_node*) calloc (1, sizeof (_cl_command_node));
}
Esempio n. 27
0
OCStackResult DeletePlugin(PIPluginBase * plugin)
{
    OCStackResult result = OC_STACK_ERROR;
    if (!plugin)
    {
        return OC_STACK_INVALID_PARAM;
    }
    DeleteResourceList(plugin);
    LL_DELETE(pluginList, plugin);
    if (plugin->type == PLUGIN_ZIGBEE)
    {
        result = ZigbeeStop((PIPlugin_Zigbee *) plugin);
    }
    return result;
}
Esempio n. 28
0
event_node* pocl_mem_manager_new_event_node ()
{
  event_node *ed = NULL;
  POCL_LOCK(mm->event_node_lock);
  if ((ed = mm->event_node_list))
    LL_DELETE (mm->event_node_list, ed);
  POCL_UNLOCK (mm->event_node_lock);
  
  if (ed)
    {
      memset (ed, 0, sizeof(event_node));
      return ed;
    }

  return calloc (1, sizeof (event_node));
}
Esempio n. 29
0
void DeleteSVCList(OicSecSvc_t* svc)
{
    if (svc)
    {
        OicSecSvc_t *svcTmp1 = NULL, *svcTmp2 = NULL;
        LL_FOREACH_SAFE(svc, svcTmp1, svcTmp2)
        {
            LL_DELETE(svc, svcTmp1);

            // Clean Owners
            OICFree(svcTmp1->owners);

            // Clean SVC node itself
            OICFree(svcTmp1);
        }
    }
Esempio n. 30
0
cl_event pocl_mem_manager_new_event ()
{
  cl_event ev = NULL;
  POCL_LOCK (mm->event_lock);
  if ((ev = mm->event_list))
    {
      LL_DELETE (mm->event_list, ev);
      POCL_UNLOCK (mm->event_lock);
      return ev;
    }
  POCL_UNLOCK (mm->event_lock);

  ev = (struct _cl_event*) calloc (1, sizeof (struct _cl_event));
  POCL_INIT_OBJECT(ev);
  ev->pocl_refcount = 1;
  return ev;
}