GithubHelp home page GithubHelp logo

elijahkash / libft Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 0.0 2.49 MB

'School 42' project. C library with my own implementation of some useful functions and modules.

License: MIT License

Makefile 0.49% C 98.57% CMake 0.95%
42 21 libft ft-printf get-next-line dynamic-array list-on-array dynamic-circle-deque

libft's Introduction

LIBFT

This project is one of the first and major in School 42. This is C library with my own implementation of some of the libc functions including some additional useful ones. At the first stage of schooling (about 10 projects for me) we had to use C language, and Standart C Library is forbidden for us! So, starting with such basic utilites as memcpy(); memmove(); strlen();, I wrote this library for use it in all of the following C projects. Now, in addition to the basic functions, it contains a number of useful modules. Here is a partial list:

  • simple memory manager
  • dynamic array (similar to a vector in c++)
  • dynamic cyclical deque
  • dynamic list, realised on array (for best performance)
  • get_next_line() (aka getline() from libc) + fast_input_gnl()
  • ft_printf() (my own printf() from stdio.h)
  • output buffer (implemented for ft_printf() but as part of the libft)
  • print_memory (like xdd util in unix)
  • qsort
  • and other

More detailed description posted on wiki

Also this library includes 3 projects of "School 42": libft, ft_get_next_line, ft_printf (Sorry for Google, but by law, I can't upload tasks.)

Foreword

  • Be welcome to use my lib, clone and fork it!
  • If you find a bug, please, create new issue (or contact with me in any way you want) to report about it! I will be glad to fix it! If you find a mistake in my spelling (because I'm from Russia, and English is not my native language), please notify me too!
  • If you clone/fork this lib and realise some new feature, you can create pull request! I am definitely interested in this!
  • Also, I will be happy if you follow me, or star this project, ecpecially if you find it usefull, or use my code!
  • For all questions be welcome to contact me in any way you want 👋

Here is my mail: [email protected]

How to use:

1. Compile

  • run make or make libft to compile libft.a
  • run make clean to delete tmp files after compile (only libft.a will be remain)
  • run make fclean to delete all files after compile
  • run make cmake if you change any filename.c/h to update the configuration of build (and include new file)
  • run make re to recompile all files

There is no real need to do this! If you change a file and run make, the project will recompile this file, as well as all files that depend on this file and relink the lib!

2. Include

To use libft in you project:

  • just #include <libft.h>
  • compile you files with -I /libft/includes
  • compile libft
  • link you binary with -L /libft -lft

3. Debug

If you run make or make libft, the compiler will compile the library with the -O3 -Wall -Wextra -Werror flags for better code performance and strict error checking! But if you want to debug some code, you probably want to ignore warnings and be able to use a debugger (lldb, gdb, etc.). In that case

  • run make debug

libftdebug.a will be created, and compiler flags now will be -g3 -Wall -Wextra.

4. Quick opportunity test

If you want to quick execute some code, to test something (does not matter what exactly), write it in /test/test.c than

  • run make test

/test/test binary file will be created! Also, it use libftdebug.a (and build it, if necessary) and use -g3 flag, so you can use debugger to debug you code!

5. If you use Visual Studio code ...

... then you can find something useful in .vscode

  • press CMD + SHIFT + B to build libft.a (default keys is VSC) - same to run make
  • press F5 to build libftdebug.a, /test/test, and start debug session of /test/test binary

6. Cmake

In fact, I use Cmake, to compile this lib. You may find CMakeLists.txt with it config.

If you use my project, as submodule for you project, and use Cmake too, you can add_subdirectory(${LIBFT_DIR}) and add_dependencies(${YOUR_PROJECT} libft) or add_dependencies(${YOUR_PROJECT_DEBUG} libftdebug) to easy configure dependencies!

Of course, first time I don't use Cmake, because it's forbidden by subject! So if you just started in 42, watch out! Write you own Makefile!

Template

Want to start new project and use my libft?

You can use THIS TEMPLATE

If you don't know nothing about template repositories, read man!

NORMINETTE

If you are part of the 42 society, you now all about the norminette and you may skip this part. Otherwise, you may discover some strange code and /file_structure in this project. This is becouse all project in 42 must be written in accordance with the NORM.

Here are the point that most affect the code:

  • You cannot have more than 5 function-definitions in a .c file.

We have programm called norminette. It check every project. If it found an error, project considered as FAIL

Contributors

  • I would like to say a few words of gratitude to my teammate @odrinkwa (@semrunner) by the ft_printf project, for develop float/double/long double part of printf! Thanks a lot!

License

  • See the LICENSE file for license rights and limitations (MIT).

Support

  • If you like my activity, you may say “thank you” to me and support me for any amount! Use 'Sponsor' button in github!

libft's People

Contributors

elijahkash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

libft's Issues

Refactor

Честно говоря, надо бы переделать структуру.
includes/ должна содеражть только публичные хедеры. остальные надо перенести к исходникам. потенциально переделать включения (и кстати поправить оформление. <> для libc "" для моих.)
Подкоректировать cmakelists под эти требования, сделать отдельный файл с сорцами можно (избавиться от макроса), перенести кросплатформенные фишки и т.д.
Подумать над грамотностью папок test/ tmp/ и размещения готовой либы.
Подкорректировать под эти изменения makefile.

При этом было бы круто соблюсти обратную совместимость (и не только для лемина но и для других приватных проектов)

Поменять хедеры.

И не забыть под изменения подогнать шаблон создания проекта основанного на libft

И проверить objdump-ом точно ли все впоряде с внешними функциями при отключении #define USE_LIBC

И согласовать все изменения с документацией

И удалить нафиг .vscode/ из проекта.

[Feature request] Not optimal memory using

Not optimal memory using in deq_align_front()
It's possible to detect min part of deq, alloc mem, copy this part in this mem, move biggest part on the right place, copy first part to the right plase, free extra mem.

small request

Please add more descriptions for your library functions.

like that:

/*
**	Return a length a null-terminated string.
**	
**	@s - null-terminated string
*/
size_t			ft_strlen(const char *s);

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.