Exemplo n.º 1
0
int	read_file(t_conf *x)
{
  char	*s;

  x->o_list = NULL;
  x->c_list = NULL;
  x->list = NULL;
  x->ptr_beg = NULL;
  x->ptr_end = NULL;
  x->b = 0;
  x->e = 0;
  x->stack = NULL;
  if ((x->ants_nb = ret_ants_nb()) <= 0)
    return (my_puterr(MSG1));
  s = nodes_filler(x, 0);
  rev_list(&x->list);
  if (links_filler(x, s) == FAIL)
    return (FAIL);
  if (chk_begend_links(x) == FAIL)
    return (FAIL);
  chk_dblcoord(x->list);
  chk_dblname(x->list);
  rev_stack(&x->stack);
  return (1);
}
int main()
{
	add(&root);
	add(&root);
	add(&root);
	disp(root);
	rev_list(root);
	disp(root);
	return 0;
}
void rev_list(DLL_t *head)
{
	DLL_t *tmp;
	if (head->next != (DLL_t *) NULL) {
		rev_list(head->next);
		tmp = head->prev;
		head->prev = head->next;
		head->next = tmp;
	} else {
		root = head;
		tmp = head->prev;
		head->prev = head->next;
		head->next = tmp;
	}
}
Exemplo n.º 4
0
int			main(void)
{
  t_list		*l;
  char			*s1;
  char			*s2;
  char			*s3;

  l = NULL;
  s1 = strdup("test1");
  s2 = strdup("test2");
  s3 = strdup("test3");
  l = push_back(&l, s1);
  l = push_back(&l, s2);
  l = push_back(&l, s3);
  printf("size : %i\n", list_size(l));
  rev_list(&l);
  dump_string_list(l);
  free_list(l);
  return (0);
}
Exemplo n.º 5
0
int		create_inter(char *key, char *key2, t_bind *bind, t_bdb **foot)
{
  if ((*foot) && (*foot)->next)
    fprintf(stderr, "Error, not at the end of the bind keys database\n");
  else
    {
      if (!(bind->key = strdup(key)) || !(bind->key2 = strdup(key2)))
	fprintf(stderr, "Error allocate memory\n");
      else
	{
	  bind->flags = INTER;
	  if (!(add_list(foot, bind)))
	    {
	      xfree(bind->key);
	      xfree(bind->key2);
	    }
	  else
	    return (EXIT_SUCCESS);
	}
    }
  xfree(bind);
  rev_list(foot);
  return (EXIT_FAILURE);
}