Exemplo n.º 1
0
int	vec_destroy(struct s_vec *vec)
{
  assert(vec != NULL);
  vec_empty(vec);
  free(vec->_data);
  return (0);
}
Exemplo n.º 2
0
int	string_split_str(const struct s_string *string,
			 const char *pattern,
			 struct s_vec *matches)
{
  char	*copy;
  char	*token;

  assert(string != NULL);
  assert(pattern != NULL);
  assert(matches != NULL);
  copy = string->_string;
  token = strsep(&copy, pattern);
  if (vec_init(matches, 0, &string_delete) == -1)
    return (-1);
  while (copy != NULL)
    {
      if (push_to_vec(matches, token) == -1)
	return (vec_empty(matches), -1);
      token = strsep(&copy, pattern);
    }
  if (push_to_vec(matches, token) == -1)
    return (vec_empty(matches), -1);
  return (0);
}
Exemplo n.º 3
0
Arquivo: vec.c Projeto: seanpringle/lt
vec_t*
vec_decref (vec_t *vec)
{
  ensure_vec(vec, __func__);

  if (--vec->ref_count == 0)
  {
    vec_empty(vec);
    arena_free(vecs, vec);
    vec_count--;
    vec_destroyed++;
    vec = NULL;
  }
  return vec;
}