Exemplo n.º 1
0
List* list_new_entry(const Entry* entry)
{
   ListData data;
   
   assert(entry_is_valid(entry));

   data.entry = entry_copy(entry);

   return list_new(LIST_ENTRY, &data);
}
Exemplo n.º 2
0
void list_insert_entry(List* list, const Entry* entry)
{
   ListData data;

   assert(list_is_valid(list));
   assert(entry_is_valid(entry));
   assert(list->type == LIST_ENTRY);

   data.entry = entry_copy(entry);

   list_insert_data(list, &data);
}
Exemplo n.º 3
0
struct usched_entry *schedule_entry_get_copy(uint64_t entry_id) {
	int errsv = 0;
	struct usched_entry *entry = NULL, *entry_dest = NULL;

	pthread_mutex_lock(&rund.mutex_apool);
	entry = rund.apool->search(rund.apool, usched_entry_id(entry_id));

	if (!entry) {
		log_warn("schedule_entry_search(): entry == NULL\n");
		pthread_mutex_unlock(&rund.mutex_apool);
		errno = EINVAL;
		return NULL;
	}

	if (!entry->reserved.psched_id) {
		log_warn("schedule_entry_get_copy(): entry->reserved.psched_id == 0\n");
		pthread_mutex_unlock(&rund.mutex_apool);
		errno = EINVAL;
		return NULL;
	}

	if (!(entry_dest = mm_alloc(sizeof(struct usched_entry)))) {
		errsv = errno;
		log_warn("schedule_entry_get_copy(): mm_alloc(): %s\n", strerror(errno));
		pthread_mutex_unlock(&rund.mutex_apool);
		errno = errsv;
		return NULL;
	}

	if (entry_copy(entry_dest, entry) < 0) {
		errsv = errno;
		log_warn("schedule_entry_get_copy(): entry_copy(): %s\n", strerror(errno));
		pthread_mutex_unlock(&rund.mutex_apool);
		mm_free(entry_dest);
		errno = errsv;
		return NULL;
	}

	pthread_mutex_unlock(&rund.mutex_apool);

	return entry_dest;
}
Exemplo n.º 4
0
Symbol* symbol_new(
   const char*  name,
   SymbolType   type,
   const Set*   set,
   int          estimated_size,
   const Entry* deflt)
{
   Symbol* sym;

   assert(name           != NULL);
   assert(strlen(name)   >  0);
   assert(set            != NULL);
   assert(estimated_size >= 0);
   
   sym = calloc(1, sizeof(*sym));

   assert(sym != NULL);
   
   sym->name    = name;
   sym->type    = type;
   sym->size    = 1;
   sym->used    = 0;
   sym->extend  = SYMBOL_EXTEND_SIZE;
   sym->set     = set_copy(set);
   sym->hash    = hash_new(HASH_ENTRY, estimated_size);
   sym->entry   = calloc(1, sizeof(*sym->entry));
   sym->deflt   = (deflt != ENTRY_NULL) ? entry_copy(deflt) : ENTRY_NULL;
   sym->next    = anchor;
   anchor       = sym;

   assert(sym->entry != NULL);

   SID_set(sym, SYMBOL_SID);
   assert(symbol_is_valid(sym));

   return sym;
}