Esempio n. 1
0
void test_list(void)
{
	struct my_list* list;
	struct my_list_item* item;
	int i;

	list = my_list_new();

	for (i = 0; i < 10; i++)
	{
		item = my_list_item_new();
		item->a = i;
		item->b = i * i;
		my_list_enqueue(list, item);
	}

	for (i = 0, item = list->head; item; i++, item = my_list_item_next(item))
	{
		CU_ASSERT(item->a == i);
		CU_ASSERT(item->b == i * i);
		/*printf("%d %d\n", item->a, item->b);*/
	}

	my_list_free(list);
}
Esempio n. 2
0
File: all.c Progetto: kiniou/ummd
static int my_target_create_fn(void *data, void *user, int flags)
{
	my_core_t *core = MY_CORE(user);
	my_port_t *port;
	my_port_conf_t *conf = MY_PORT_CONF(data);
	my_port_impl_t *impl;

	impl = my_target_impl_find(conf);
	if (!impl) {
		return 0;
	}

	port = my_port_create(core, conf, impl);
	if (port) {
		my_list_enqueue(core->targets, port);
	}

	return 0;
}
Esempio n. 3
0
int		params_get_files(t_list *programs, int argc,
				 const char **argv)
{
  t_program	*program;
  int		i;

  if ((program = program_new()) == NULL)
    return (error_int(RET_FAILURE, ERR_GENERAL));
  i = 1;
  while (i < argc)
    {
      if (fill_program(program, i, argc, argv) == RET_FAILURE)
	return (RET_FAILURE);
      if (program->file)
	{
	  if (my_list_enqueue(programs, program) == RET_FAILURE)
	    return (error_int(RET_FAILURE, ERR_GENERAL));
	  if (i + 1 < argc && (program = program_new()) == NULL)
	    return (error_int(RET_FAILURE, ERR_GENERAL));
	}
      i++;
    }
  return (RET_SUCCESS);
}