Exemplo n.º 1
0
 // 登録
 CALLBACK_ID set(F func, void *arg)
 {
   Item *item = get_free_item();
   if (item == NULL) {
     return 0;
   }
   item->id = get_next_id();
   item->entry = func;
   item->arg = arg;
   return item->id;
 }
Exemplo n.º 2
0
Arquivo: list.c Projeto: rgs1/libsmall
static void * do_list_append(list *l, void *value)
{
  list_item *item = NULL;

  if (l->count == l->size)
    return NULL;

  item = get_free_item(l);
  item->value = value;
  item->next = NULL;

  if (l->tail)
    l->tail->next = item;

  l->tail = item;

  if (l->count == 1)
    l->head = item;

  return item;
}
Exemplo n.º 3
0
Arquivo: list.c Projeto: rgs1/libsmall
SMALL_EXPORT void * list_prepend(list *l, void *value)
{
  list_item *item = NULL;

  LOCK(l);

  if (l->count == l->size)
    goto out;

  item = get_free_item(l);
  item->value = value;
  item->next = l->head;
  l->head = item;

  if (l->count == 1)
    l->tail = item;

out:
  UNLOCK(l);
  return item;
}