Пример #1
0
char	*get_next_line(const int fd)
{
  char		*buffer;
  static char	memory[SIZE_READ + 1];
  int		w;
  int		lr;

  w = 0;
  lr = SIZE_READ;
  if (SIZE_READ <= 0)
    return (NULL);
  buffer = NULL;
  while ((!test_nl(memory) || !w) && lr == SIZE_READ)
    {
      if (!memory[0])
	if ((lr = read(fd, memory, SIZE_READ)) <= 0 && w == 0)
	  return (NULL);
      w = w + SIZE_READ;
      memorize(&w, &buffer, memory);
      if (buffer == NULL)
	return (NULL);
    }
  w = 0;
  lr = 1;
  while (w + 1 < SIZE_READ && memory[w])
    memory[w++] = memory[lr++];
  memory[w] = '\0';
  return (buffer);
}
Пример #2
0
TableItem getMemorize(Vert* vert, int rootIndex, int parent, TableItem(*table)[MAX]){
	TableItem item = table[rootIndex][parent];
	if (item.use == false){
		memorize(vert, rootIndex, parent, table);	//테이블에 없으면 찾는다.
		item = table[rootIndex][parent];
	}
	return item;
}