-
Notifications
You must be signed in to change notification settings - Fork 0
First steps
Ilya Kashnitskiy edited this page Feb 17, 2020
·
6 revisions
int main(void)
{
ft_memman_init();
/* YOUR CODE */
ft_force_buff();
ft_memman_clean();
return (0);
}
Same as in test.c
-
Why? And what does it mean?
- I wrote a simple memory manager. In short, it collects and stores all the memory allocated by
malloc(). All other functions in the library (again: by default) use this manager. At the beginning of each program, it must be initialized and deleted at the end. This is exactly what theft_memman_init()andft_memman_clean()functions do. And if you are going to use my libft, you probably should use them too.
Take a look at the Memory manager page for details.
- For best performance,
ft_printf ()uses output buffer mechanics. And for extremely performance (again: by defaul) it doesn’t guarantee to print something in stdout. I set output buffer size at8192(8 kb). If it is filled, it is displayed (8 kb at a time). And in order to guarantee that everything that we wanted to print will really be printed, it is necessary to callft_force_buff()beforeexit()the program.
Take a look at the Output buffer page for details.
- I wrote a simple memory manager. In short, it collects and stores all the memory allocated by
-
I started using/exploring your libft, and found that all the functions declared in ft_libc.h implemented like this ft_strlen.c. Why and what for?
- By libft subject and in all next
Cprojects, we can't use functions from libc (except some basic likemalloc(), free(), write()and e.g.). So all this functions have my own (and fully correct) implementation. - But this is a good library! And I will continue to use it in all of my next
Cprojects (even after school 21). So it would be nice to have an easy way to get all the power of theClanguage and use libc functions instead of mine! - In addition, it’s nice to have a simple way to explore how the program’s performance will change when switching from self-written to standard functions.
- By libft subject and in all next
-
What if I don't want to use the memory manager or want the printf to immediately output information? And how can I switch between self-written and standard functions?
- Don't worry! It's really easy to change! Take a look at the libft_mod page for an answer!