示例#1
0
int		read_file(const t_hs filename, t_glist_hs *lines)
{
  char		*data;
  int		fd;
  ssize_t	file_length;
  t_hs		ths;
  t_glist_hs	new_lines;

  if ((file_length = get_file_length(filename)) == -1)
    return (-1);
  if ((fd = open_file(filename, O_RDONLY)) == -1)
    return (-1);
  data = egc_malloc_atomic(file_length + 1);
  if (read(fd, data, file_length) == -1)
    {
      close(fd);
      return (-1);
    }
  close(fd);
  ths = hs(data);
  if ((int)hs_length(ths) != file_length)
    return (-1);
  new_lines = hs_split(ths, hs("\n"));
  glist_hs_append_all(lines, &new_lines);
  return (0);
}
示例#2
0
文件: malloc.c 项目: antoinegergy/egc
static void     test_malloc_atomic(void)
{
  size_t        size;
  void          *data;

  size = 123;
  data = egc_malloc_atomic(size);
  check_allocated_block(data, size);
  ASSERT(1);
}