Giter Site home page Giter Site logo

getnextline's Introduction

GetNextLine

Mini projet en C de première année Epitech.

Le GetNextLine (GNL) permet de récupérer ligne par ligne un file descriptor à la façon de GetLine.

Ce repo peut vous servir d'exemple, il passe 100% des tests. Attention au -42 !

getnextline's People

Watchers

James Cloos avatar Thibaut Cornolti avatar

getnextline's Issues

The current version is having troubles facing leak

Expected behavior and actual behavior:

The program should free every memory it allocates except the one used to return a pointer to the string.
The actual method is leaking about 60% of total memory.

Steps to reproduce the problem:

Use the current version (COMMIT 6eb8c36) and a simple main function that iterates over a file's content and displays (then frees) each string returned by the GNL.

~> Example main function:
int main(int ac, char **av)
{
  char *s;
  int	fd;

  if (ac < 2)
    return (1);
  fd = open(av[1], O_RDONLY);
  if (fd == -1)
    return (1);
  while ((s = get_next_line(fd)) != NULL)
    {
      puts(s);
      free(s);
    }
  close(fd);
  return (0);
}

Using the previous main with 'get_next_line.h' as an argument and valgrind to reveal memory leaks outputs the following:

total heap usage: 118 allocs, 21 frees, 3,415 bytes allocated.

BON EN VRAI BALLEC GG 100% M9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.