static void
search_item(TableIndex index, void *key_ptr, int key_len, void *info_ptr, void *arg)
{
    LoaderInfo  *info;
    SearchData  *data;

    HPROF_ASSERT(info_ptr!=NULL);
    HPROF_ASSERT(arg!=NULL);
    info        = (LoaderInfo*)info_ptr;
    data        = (SearchData*)arg;
    if ( data->loader == info->globalref ) {
        /* Covers when looking for NULL too. */
        HPROF_ASSERT(data->found==0); /* Did we find more than one? */
        data->found = index;
    } else if ( data->env != NULL && data->loader != NULL &&
                info->globalref != NULL ) {
        jobject lref;

        lref = newLocalReference(data->env, info->globalref);
        if ( lref == NULL ) {
            /* Object went away, free reference and entry */
            free_entry(data->env, index);
        } else if ( isSameObject(data->env, data->loader, lref) ) {
            HPROF_ASSERT(data->found==0); /* Did we find more than one? */
            data->found = index;
        }
        if ( lref != NULL ) {
            deleteLocalReference(data->env, lref);
        }
    }

}
Пример #2
0
/**
 * Creates a new cache entry and then puts it into the cache's hashtable.
 *
 * @param peer_id the index of the peer to tag the newly created entry
 * @return the newly created entry
 */
static struct CacheEntry *
add_entry (unsigned int peer_id)
{
  struct CacheEntry *entry;

  GNUNET_assert (NULL != cache);
  if (cache_size == GNUNET_CONTAINER_multihashmap32_size (cache))
  {
    /* remove the LRU head */
    entry = cache_head;
    GNUNET_assert (GNUNET_OK ==
                   GNUNET_CONTAINER_multihashmap32_remove (cache, (uint32_t)
                                                           entry->peer_id,
                                                           entry));
    free_entry (entry);
  }
  entry = GNUNET_new (struct CacheEntry);
  entry->peer_id = peer_id;
  GNUNET_assert (GNUNET_OK ==
                 GNUNET_CONTAINER_multihashmap32_put (cache,
                                                      (uint32_t) peer_id,
                                                      entry,
                                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
  GNUNET_CONTAINER_DLL_insert_tail (cache_head, cache_tail, entry);
  return entry;
}
Пример #3
0
int
push_to_dirstack(const char *ld, const char *lf, const char *rd, const char *rf)
{
	if(stack_top == stack_size)
	{
		stack_entry_t *s = reallocarray(stack, stack_size + 1, sizeof(*stack));
		if(s == NULL)
		{
			return -1;
		}

		stack = s;
		stack_size++;
	}

	stack[stack_top].lpane_dir = strdup(ld);
	stack[stack_top].lpane_file = strdup(lf);
	stack[stack_top].rpane_dir = strdup(rd);
	stack[stack_top].rpane_file = strdup(rf);

	if(stack[stack_top].lpane_dir == NULL ||
			stack[stack_top].lpane_file == NULL ||
			stack[stack_top].rpane_dir == NULL || stack[stack_top].rpane_file == NULL)
	{
		free_entry(&stack[stack_top]);
		return -1;
	}

	stack_top++;
	changed = 1;

	return 0;
}
Пример #4
0
void mark_deleted_entry( struct entry_t * entry )
{
    free_entry( entry );
    int total_size = entry->word_len + entry->content_len;
    entry->word_len = 0;
    entry->content_len = total_size;
}
Пример #5
0
static void
pwdfile_search( struct ldop *op, FILE *ofp )
{
    struct passwd	*pw;
    struct ldentry	*entry;
    int			oneentry;

    oneentry = ( strchr( op->ldop_dn, '@' ) != NULL );

    for ( pw = getpwent(); pw != NULL; pw = getpwent()) {
	if (( entry = pw2entry( op, pw )) != NULL ) {
	    if ( oneentry ) {
		if ( strcasecmp( op->ldop_dn, entry->lde_dn ) == 0 ) {
		    write_entry( op, entry, ofp );
		    break;
		}
	    } else if ( test_filter( op, entry ) == LDAP_COMPARE_TRUE ) {
			write_entry( op, entry, ofp );
	    }
	    free_entry( entry );
	}
    }
    endpwent();

    write_result( ofp, LDAP_SUCCESS, NULL, NULL );
}
Пример #6
0
/**
 * Clears expired entries in the ARP table.
 *
 * This function should be called every ETHARP_TMR_INTERVAL milliseconds (5 seconds),
 * in order to expire entries in the ARP table.
 */
void
etharp_tmr(void)
{
  u8_t i;

  LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n"));
  /* remove expired entries from the ARP table */
  for (i = 0; i < ARP_TABLE_SIZE; ++i) {
    u8_t state = arp_table[i].state;
    if (state != ETHARP_STATE_EMPTY
#if ETHARP_SUPPORT_STATIC_ENTRIES
      && (arp_table[i].static_entry == 0)
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
      ) {
      arp_table[i].ctime++;
      if ((arp_table[i].ctime >= ARP_MAXAGE) ||
          ((arp_table[i].state == ETHARP_STATE_PENDING)  &&
           (arp_table[i].ctime >= ARP_MAXPENDING))) {
        /* pending or stable entry has become old! */
        LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired %s entry %"U16_F".\n",
             arp_table[i].state == ETHARP_STATE_STABLE ? "stable" : "pending", (u16_t)i));
        /* clean up entries that have just been expired */
        free_entry(i);
      }
#if ARP_QUEUEING
      /* still pending entry? (not expired) */
      if (arp_table[i].state == ETHARP_STATE_PENDING) {
        /* resend an ARP query here? */
      }
#endif /* ARP_QUEUEING */
    }
  }
}
Пример #7
0
void free_hash(h_entry_t* hash, unsigned int hash_size, int do_cell)
{
    int   i;   /* index for hash entries */
    entry_t *tmp, /* just a temporar variable */
			*it;  /* iterator through cells of a has entry */
    if(!hash || hash_size<=0)
		return;
    
	/* free memory ocupied by all hash entries */
	for(i=0; i<hash_size; i++)
	{
		/* iterator through the i-th entry of the hash */
		it = hash[i].e;
		
		/* as long as we have a cell */
		while(it != NULL)
		{
			/* retains the next cell */
	    	tmp = it->n;
			free_entry(it, do_cell);
	    	
			/* the iterator points up to the next cell */
			it = tmp;
		}
		lock_destroy(&hash[i].lock);
    }

	shm_free(hash);
}
static int demote_cblock(struct smq_policy *mq,
			 struct policy_locker *locker,
			 dm_oblock_t *oblock)
{
	struct entry *demoted = q_peek(&mq->clean, mq->clean.nr_levels, false);
	if (!demoted)
		/*
		 * We could get a block from mq->dirty, but that
		 * would add extra latency to the triggering bio as it
		 * waits for the writeback.  Better to not promote this
		 * time and hope there's a clean block next time this block
		 * is hit.
		 */
		return -ENOSPC;

	if (locker->fn(locker, demoted->oblock))
		/*
		 * We couldn't lock this block.
		 */
		return -EBUSY;

	del(mq, demoted);
	*oblock = demoted->oblock;
	free_entry(&mq->cache_alloc, demoted);

	return 0;
}
Пример #9
0
void CLIB_DECL free(void *memory)
{
	memory_entry *entry;

	// allow NULL frees
	if (memory == NULL)
		return;

	// error if no entry found
	entry = find_entry(memory);
	if (entry == NULL)
	{
		if (winalloc_in_main_code)
		{
			fprintf(stderr, "Error: free a non-existant block\n");
			osd_break_into_debugger("Error: free a non-existant block");
		}
		return;
	}
	free_entry(entry);

	// free the memory
	if (USE_GUARD_PAGES)
		VirtualFree((UINT8 *)memory - ((UINT32)memory & (PAGE_SIZE-1)) - PAGE_SIZE, 0, MEM_RELEASE);
	else
		GlobalFree(memory);

#if LOG_CALLS
	logerror("free #%06d size = %d\n", entry->id, entry->size);
#endif
}
Пример #10
0
static inline void __noinstrument
do_func_exit(struct kfi_run* run, void *this_fn, void *call_site)
{
	struct kfi_entry* entry;
	unsigned long exittime;
	unsigned long delta;
	int entry_i;

	if ((entry_i = find_entry(run, this_fn, in_interrupt() ?
				  INTR_CONTEXT : current->pid)) < 0) {
#ifdef KFI_DEBUG
		run->notfound++;
#endif
		return;
	}
	
	entry = &run->log[entry_i];

	// calc delta
	exittime = update_usecs_since_boot() - run->start_trigger.mark;
	delta = exittime - entry->time;
	
	if ((run->filters.min_delta && delta < run->filters.min_delta) ||
	    (run->filters.max_delta && delta > run->filters.max_delta)) {
#ifdef KFI_DEBUG
		run->filters.cnt.delta++;
#endif
		free_entry(run, entry_i);
	} else {
		entry->delta = delta;
	}
}
Пример #11
0
/*
 * Check the sigq for any pending signals.  If any are found,
 * preform the required actions and remove them from the queue.
 */
PUBLIC void
sig_check(void)
{
	q_entry_t *e;
	sigset_t nset;
	sigset_t oset;
	void (*handler)(int);
	int signo;

	(void)sigfillset(&nset);
	(void)sigprocmask(SIG_SETMASK, &nset, &oset);

	while ((e = sigq.qe_first) != NULL) {
		signo = e->qe_signo;
		handler = e->qe_handler;

		/*
		 * Remove the entry from the queue and free it.
		 */
		sigq.qe_first = e->qe_next;
		if (sigq.qe_first == NULL)
			sigq.qe_last = &sigq.qe_first;
		free_entry(e);

		if (handler == SIG_DFL || handler == SIG_IGN) {
			assert(/*CONSTCOND*/ 0);	/* These should not get posted. */
		}
		else {
			(void)sigprocmask(SIG_SETMASK, &oset, NULL);
			handler(signo);
			(void)sigprocmask(SIG_SETMASK, &nset, NULL);
		}
	}
	(void)sigprocmask(SIG_SETMASK, &oset, NULL);
}
Пример #12
0
/* We `seal' the path by linking everything into one big list.  Then
   we provide a way to iterate through the sealed list.  If PRINT is
   true then we print the final class path to stderr.  */
void
jcf_path_seal (int print)
{
  struct entry *secondary;

  sealed = include_dirs;
  include_dirs = NULL;

  if (classpath_user)
    {
      secondary = classpath_user;
      classpath_user = NULL;
    }
  else
    {
      if (! classpath_env)
	add_entry (&classpath_env, ".", 0);

      secondary = classpath_env;
      classpath_env = NULL;
    }


  free_entry (&classpath_user);
  free_entry (&classpath_env);

  append_entry (&sealed, secondary);
  append_entry (&sealed, sys_dirs);
  append_entry (&sealed, extensions);
  sys_dirs = NULL;
  extensions = NULL;

  if (print)
    {
      struct entry *ent;
      fprintf (stderr, "Class path starts here:\n");
      for (ent = sealed; ent; ent = ent->next)
	{
	  fprintf (stderr, "    %s", ent->name);
	  if ((ent->flags & FLAG_SYSTEM))
	    fprintf (stderr, " (system)");
	  if ((ent->flags & FLAG_ZIP))
	    fprintf (stderr, " (zip)");
	  fprintf (stderr, "\n");
	}
    }
}
Пример #13
0
void
clean_stack(void)
{
	while(stack_top > 0)
	{
		free_entry(&stack[--stack_top]);
	}
}
Пример #14
0
Object *extract(Binding *binding, char *key) {
    Entry **owner = find_owner(binding, key);
    if (owner == NULL) {
        return NULL;
    }
    Entry *entry = *owner;
    *owner = entry->next;
    return free_entry(entry);
}
Пример #15
0
static int process_entry_ref(entry_ref_t *entry_ref, process_params_t *params)
{
	char *data = NULL;
	int dsize = 0;
	entry_t *entry = NULL;
	char *xcap_uri;
	int res;
	
	/* DEBUG_LOG("processing entry-ref with ref \'%s\'\n", STR_OK(entry_ref->ref)); */
	
	if (!entry_ref) return RES_OK;
	if (!entry_ref->ref) return RES_OK;
	
	if (add_uri_to_traversed(params, entry_ref->ref) != 0) {
		/* It is existing yet? */
		ERROR_LOG("Duplicate URI in traversed set\n");
		return RES_BAD_GATEWAY_ERR; /* 502 Bad GW */
	}

	/* XCAP query for the ref uri */
	xcap_uri = relative2absolute_uri(params->xcap_root, entry_ref->ref);
	res = xcap_query(xcap_uri, params->xcap_params, &data, &dsize);
	if (res != 0) {
		ERROR_LOG("XCAP problems for uri \'%s\'\n", xcap_uri ? xcap_uri: "???");
		if (data) cds_free(data);
		if (xcap_uri) cds_free(xcap_uri);
		return RES_BAD_GATEWAY_ERR; /* 502 Bad GW */
	}
	if (xcap_uri) cds_free(xcap_uri);

	/* parse document as an entry element */
	if (parse_entry_xml(data, dsize, &entry) != 0) {
		ERROR_LOG("Parsing problems!\n");
		if (entry) free_entry(entry);
		if (data) cds_free(data);
		return RES_BAD_GATEWAY_ERR; /* 502 Bad GW */
	}
	if (data) cds_free(data);
	if (!entry) return RES_INTERNAL_ERR; /* ??? */

	res = process_entry(entry, params);
	free_entry(entry);
	return res;
}
Пример #16
0
void LoaderConstraintTable::merge_loader_constraints(
                                                   LoaderConstraintEntry** pp1,
                                                   LoaderConstraintEntry** pp2,
                                                   klassOop klass) {
  // make sure *pp1 has higher capacity
  if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) {
    LoaderConstraintEntry** tmp = pp2;
    pp2 = pp1;
    pp1 = tmp;
  }

  LoaderConstraintEntry* p1 = *pp1;
  LoaderConstraintEntry* p2 = *pp2;

  ensure_loader_constraint_capacity(p1, p2->num_loaders());

  for (int i = 0; i < p2->num_loaders(); i++) {
    int num = p1->num_loaders();
    p1->set_loader(num, p2->loader(i));
    p1->set_num_loaders(num + 1);
  }

  if (TraceLoaderConstraints) {
    ResourceMark rm;
    tty->print_cr("[Merged constraints for name %s, new loader list:",
                  p1->name()->as_C_string()
                  );

    for (int i = 0; i < p1->num_loaders(); i++) {
      tty->print_cr("[   [%d]: %s", i,
                    SystemDictionary::loader_name(p1->loader(i)));
    }
    if (p1->klass() == NULL) {
      tty->print_cr("[... and setting class object]");
    }
  }

  // p1->klass() will hold NULL if klass, p2->klass(), and old
  // p1->klass() are all NULL.  In addition, all three must have
  // matching non-NULL values, otherwise either the constraints would
  // have been violated, or the constraints had been corrupted (and an
  // assertion would fail).
  if (p2->klass() != NULL) {
    assert(p2->klass() == klass, "constraints corrupted");
  }
  if (p1->klass() == NULL) {
    p1->set_klass(klass);
  } else {
    assert(p1->klass() == klass, "constraints corrupted");
  }

  *pp2 = p2->next();
  FREE_C_HEAP_ARRAY(oop, p2->loaders());
  free_entry(p2);
  return;
}
static void __remove_mapping(struct smq_policy *mq, dm_oblock_t oblock)
{
	struct entry *e;

	e = h_lookup(&mq->table, oblock);
	BUG_ON(!e);

	del(mq, e);
	free_entry(&mq->cache_alloc, e);
}
Пример #18
0
// FREE AVL
static void _free_avl(struct avl_nodo *nodo){
  if(nodo == NULL) return;

  _free_avl(nodo->izq);
  _free_avl(nodo->der);

  free_entry(nodo->e);
  free(nodo->e);
  free(nodo);
}
Пример #19
0
/**
 * Iterator over hash map entries.
 *
 * @param cls closure
 * @param key current key
 * @param value value in the hash map
 * @return GNUNET_YES if we should continue to
 *         iterate,
 *         GNUNET_NO if not.
 */
static int
cache_clear_iterator (void *cls, uint32_t key, void *value)
{
  struct CacheEntry *entry = value;

  GNUNET_assert (NULL != entry);
  GNUNET_assert (GNUNET_YES ==
                 GNUNET_CONTAINER_multihashmap32_remove (cache, key, value));
  free_entry (entry);
  return GNUNET_YES;
}
Пример #20
0
/*
 Frees a entry
 entry = entry to free
*/
void memory_manager_free(void *memory) {
	if (!memory) {											/* check it's not null */
		return;
	}
	uint32_t size = sizeof(memory) + sizeof(memory_page);	/* get the real size of the page */
	if (!(size & ~327684)) {								/* if we have a bucket big enough */					
		free_entry(memory - sizeof(memory_page), size);
	} else {
		free(memory);										/* else its an os page */
	}
}
Пример #21
0
void
free_user(user *u) {
	entry *e, *ne;

	free(u->name);
	for (e = u->crontab;  e != NULL;  e = ne) {
		ne = e->next;
		free_entry(e);
	}
	free(u);
}
Пример #22
0
int remove_from_hash(h_entry_t* hash, unsigned int hash_size, dc_t* cell, int type)
{
	int hash_entry=0;
	entry_t *it, *tmp;
	
	if(!cell)
		return 0;
	
	if(!hash) 
		return -1;
    
	/* find the list where the cell must be */
	if(type==DHASH)
		hash_entry = get_hash_entry(cell->dhash, hash_size);
	else 
		if(type==CHASH)
			hash_entry = get_hash_entry(cell->code, hash_size);
	else
		return -1;	


	lock_get(&hash[hash_entry].lock);
	
	/* first element of the list */	
	it = hash[hash_entry].e;

	/* find the cell in the list */
	/* a double linked list in the hash is kept alphabetically
	* or numerical ordered */    
	tmp = NULL;
	while(it!=NULL && it->dc != cell)
	{
		tmp = it;
		it = it->n;
	}
	
	if(it)
	{
		if(tmp)
			tmp->n = it->n;
		else
			hash[hash_entry].e = it->n;

		if(it->n)
			it->n->p = it->p;

		free_entry(it, (type==DHASH?ERASE_CELL:NOT_ERASE_CELL));
	}
	
	lock_release(&hash[hash_entry].lock);

	return 0;
}
static int __remove_cblock(struct smq_policy *mq, dm_cblock_t cblock)
{
	struct entry *e = get_entry(&mq->cache_alloc, from_cblock(cblock));

	if (!e || !e->allocated)
		return -ENODATA;

	del(mq, e);
	free_entry(&mq->cache_alloc, e);

	return 0;
}
Пример #24
0
static void free_entry(ReplayMessageTreeEntry *entry)
{
  ReplayMessageTreeEntry *child;

  while ((child = entry->first_child) != NULL)
  {
    entry->first_child = child->next;
    free_entry(child);
  }
  gtk_tree_path_free(entry->tree_path);
  g_free(entry->name);
  g_free(entry);
}
Пример #25
0
void pa_scache_free_all(pa_core *c) {
    pa_scache_entry *e;

    pa_assert(c);

    while ((e = pa_idxset_steal_first(c->scache, NULL)))
        free_entry(e);

    if (c->scache_auto_unload_event) {
        c->mainloop->time_free(c->scache_auto_unload_event);
        c->scache_auto_unload_event = NULL;
    }
}
Пример #26
0
static void
free_enumeration(struct enumeration *enumeration)
{
	struct entry *e, *e_next;

	free(enumeration->name);
	free(enumeration->uppercase_name);
	free_description(enumeration->description);

	wl_list_for_each_safe(e, e_next, &enumeration->entry_list, link)
		free_entry(e);

	free(enumeration);
}
Пример #27
0
int node_put_data_packet_force(struct node *node, struct packet *pkt,
		cb_fn *callback, void *data)
{
	int ret;
	struct entry *e;

	e = create_cb_entry(pkt, callback, data);
	if (!e)
		return -1;
	ret = queue_put_force(e, node->data_q);
	if (ret < 0)
		free_entry(e);

	return ret;
}
Пример #28
0
int node_put_data_packet(struct node *node, struct packet *pkt)
{
	struct entry *e;

	e = create_entry(pkt);
	if(e == NULL) {
		return -1;
	}

	if(queue_put(e, node->data_q) < 0){
		free_entry(e);
		return -1;
	}
	return 0;
}
Пример #29
0
struct packet *node_get_meta_packet(struct node *node)
{
	struct entry *e;
	struct packet *pkt;

	e = queue_get(node->meta_q);
	if(e == NULL) {
		return NULL;
	}

	pkt = (struct packet *)e->data;
	free_entry(e);

	return pkt;
}
Пример #30
0
Binding *free_binding(Binding *binding) {
    if (binding->reference_count > 1L) {
        binding->reference_count--;
        return binding->parent;
    }
    Binding *parent = binding->parent;
    Entry *entry = binding->first;
    while (entry != NULL) {
        Entry *next = entry->next;
        destroy(free_entry(entry));
        entry = next;
    }
    free_binding(binding->parent);
    free(binding);
    return parent;
}