Skip to content

Commit 692a5a1

Browse files
committed
update readme, remove some corewar specific modifications
1 parent 3ea46ae commit 692a5a1

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

README.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11

2+
23
# Libft
3-
My own libC to use at 42.
4-
Most of the functions are defined in libft.h (and even if they're defined somewhere else you will find a comment in libft.h)
4+
My own libC to use at 42.
5+
Most of the functions are defined in `libft.h`, appart from the t_vec4 related ones (because they are all inline).
6+
`intrisics.h` contains the structures t_lst, t_vector, t_vec4, t_queue, (...) and all the defines.
7+
## Some stats
8+
- 128 files for ~4000 lines of code (not counting the headers).
9+
- Some functions as fast or faster than the libC (depending on your system) without the use of any ASM.
510
## What's inside
6-
My libft contains lots of functions and datatypes with their own 'operators', all of them are described in libft.h and again by the folder names in ./src
11+
My libft contains lots of functions and datatypes with their own 'operators', most of them are described in `libft.h`. The folder names in `./src` are also quite descriptive.
712
### At the time of writing, this libft contains :
813
#### libmem
9-
- ft_bzero (uses AVX/SSE !)
10-
- ft_mem(...) Functions in here are generaly optimized to use the biggest registers available and use as few cpu cycles as possible (yay AVX)
14+
- ft_bzero
15+
- ft_mem(...)
1116
#### libstr
1217
- ft_str(...)
1318
#### libnb
@@ -25,6 +30,7 @@ My libft contains lots of functions and datatypes with their own 'operators', al
2530
- ft_vprintf
2631
- (...)
2732
supports pUudioxXsfcbr ('b' prints an int in binary, 'r' reads a file descriptor)
33+
2834
#### t_lst
2935
Operators for the t_lst datatype. t_lst being defined as :
3036
```c
@@ -36,9 +42,8 @@ typedef struct s_list
3642
} t_list;
3743

3844
```
39-
45+
4046
#### t_queue
41-
4247
Operators for the t_queue datatype. t_queue being defined as :
4348
```c
4449
typedef struct s_queue
@@ -50,6 +55,7 @@ typedef struct s_queue
5055
} t_queue;
5156
```
5257
t_queue is a 'rotary' queue based on an array, it's *really* fast
58+
5359
#### t_vec4
5460
Operators for an implementation of vectors of 4 floats (x, y, z, w) using SSE (__m128) :
5561
```c
@@ -66,5 +72,9 @@ typedef union u_vec4
6672
} t_vec4;
6773
```
6874
All the operators in there are inline and included by 'libft.gen' at compile time (I have to resort to this type of trickery because of 42s restrictive norme).
75+
#### t_garbage
76+
A simple (but still 12 files and ~200 LOC) garbage collector for C.
77+
It's utterly stupid but basically needed because of some bad people at 42.
78+
6979
#### other stuff
70-
There's like... msg_exit ("a printf for crashing cleanly")
80+
There's like... msg_exit ("a printf for crashing cleanly")

src/libmem/ft_memcpy.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: awoimbee <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2018/10/23 01:06:53 by awoimbee #+# #+# */
9-
/* Updated: 2019/05/24 14:02:17 by awoimbee ### ########.fr */
9+
/* Updated: 2019/06/03 17:14:15 by awoimbee ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -47,7 +47,7 @@ static void sse_memcpy(void *restrict d, const void *restrict s, size_t n)
4747
{
4848
while (n >= sizeof(__m128i))
4949
{
50-
_mm_storeu_si128((__m128i*)d, _mm_loadu_si128(s));
50+
_mm_storeu_si128(d, _mm_loadu_si128(s));
5151
s += sizeof(__m128i);
5252
d += sizeof(__m128i);
5353
n -= sizeof(__m128i);

src/libstr/ft_strchr.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: awoimbee <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2018/10/26 12:47:06 by awoimbee #+# #+# */
9-
/* Updated: 2019/05/11 00:12:26 by awoimbee ### ########.fr */
9+
/* Updated: 2019/06/03 17:18:16 by awoimbee ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -19,6 +19,8 @@
1919

2020
char *ft_strchr(const char *s, int c)
2121
{
22+
if (c == '\0')
23+
return ((char*)&s[ft_strlen(s)]);
2224
while (*s)
2325
{
2426
if (*s == (char)c)

0 commit comments

Comments
 (0)