Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42 Cursus' libft

This repo is my first project as a cadet @42rio.
It acts as both a study project on replicating libc functions, as well as a developer toolbelt to be used throughout the cursus.

Install

$> git clone https://github.com/Grsaiago/libft <path where to put the lib> && cd <path to lib>;
$> make

Don't forget to link the lib with the -lft -L$(path_to_lib) on your project's makefile

make supports the following flags. (the flags already compile with the bonus part)

  • all or simply make -> Compiles everything and gets the lib ready to go!
  • make clean -> Removes the object files.
  • make fclean -> Removes the object files, as well as the .a file
  • make re -> Removes the object and .a files and recompiles everything.

Functions List

Functions from <stdio.h>

  • ft_printf - my implementation of the printf function.

Functions from <ctype.h>

Functions from <stdlib.h>

  • ft_atoi - converts ASCII to integer.
  • ft_calloc - allocate and initialize to 0 a block of memory.

Functions from <string.h> && <strings.h>

  • ft_strlen - gets the lenght of a null terminated string.
  • ft_strdup - duplicates a string (with malloc).
  • ft_strnstr - searches for the occurence of a byte stream inside another byte stream.
  • ft_strchr - searches for the first occurence of a byte in a byte stream.
  • ft_strrchr - searches for the last occurence of a byte in a byte stream.
  • ft_strlcpy - copies the string src to dst.
  • ft_strlcat - concatenates two strings.
  • ft_strncmp - compares the first n bytes of two byte streams.
  • ft_memset - fill a byte stream with a value.
  • ft_bzero - fill a byte stream with zero.
  • ft_memcpy - copy a byte stream (doesn't account for overlapping memory blocks).
  • ft_memmove - copy a byte stream (accounts for overlapping memory blocks).
  • ft_memchr - search for a byte in the first n bytes of a byte stream.
  • ft_memcmp - compare two byte streams.

Functions from <math.h>

Nonstandard functions

  • ft_itoa - returns a malloc'd string from an int.
  • ft_strndup - returns a malloc'd copy of the first n bytes of a string.
  • ft_substr - creates a new string from a portion of a given string.
  • ft_strjoin - joins two strings (with malloc).
  • ft_strtrim - trailes off the matching char from the beginning and end of a string.
  • ft_split - splits a string into malloc'd matrix.
  • ft_free_mat - frees a malloc'd matrix.
  • ft_strmapi - returns malloc'd string that is the result of successive iterations of a function over a given string.
  • ft_striteri - iterates a given function over each position of a given string.
  • ft_putchar - prints a char to stdout.
  • ft_putchar_fd - writes a char to the given file descriptor.
  • ft_putstr - writes a string to stdout.
  • ft_putstr_fd - writes a string to the given file descriptor.
  • ft_putendl - writes a string followed by a \n to stdout.
  • ft_putendl_fd - writes a string followed by a \n to the given file descriptor.
  • ft_putnbr_fd - writes a number to stdout.
  • ft_putnbr_fd - writes a number into the given file descriptor.
  • ft_printhex - prints to stdout a number as it's hexadecimal format.
  • ft_printptr - prints to stdout an address in 0x0hex format.
  • get_next_line - my implementation of the GNU get_next_line.
  • samrtpointer - my implementation of Snaipe's smart pointers. (check his original work here)

Linked list functions

  • ft_lstnew - creates a new node.
  • ft_lstadd_front - adds a new node to the front of the list.
  • ft_lstadd_back - adds a new node to the back of the list.
  • ft_lstsize - gets the size of the list.
  • ft_lstlast - gets the last node of the list.
  • ft_lstdelone - deletes a node from the list.
  • ft_lstclear - deletes the whole list.
  • ft_lstiter - iterates a function over the content of each node.
  • ft_lstmap - returns a new list that is the result iterations over every node of the list.
  • ft_lst_remove_if - removes a node if the compare function returns true over a sample data and the contents of said node.

About

rewriting a bunch of functions from the C stdlib

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages