https://github.com/k1ngmar/libkm
π Libc rewrite
https://github.com/k1ngmar/libkm
c libc libft library
Last synced: about 2 months ago
JSON representation
π Libc rewrite
- Host: GitHub
- URL: https://github.com/k1ngmar/libkm
- Owner: K1ngmar
- License: mit
- Created: 2022-07-25T13:57:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T15:27:44.000Z (over 1 year ago)
- Last Synced: 2025-04-06T21:50:05.452Z (about 2 months ago)
- Topics: c, libc, libft, library
- Language: C
- Homepage:
- Size: 175 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# πlibkm
Inspired by the 42 project Libft where we had to rewrite a bunch of libc functions with a couple additional ones, this project improves upon my libft and aims to be safer, cleaner, more complete and performant!## π₯ Install
```bash
# clone the repository
$ git clone https://github.com/K1ngmar/libkm.git# build the repo
$ make -C libkm# link the headers with
$ cc -o $SOURCE -I$LIBKM_LOCATION/includes# link it with your project
$ cc -o $OBJECTS -L$LIBKM_LOCATION/libkm.a -lkm
```## π³ Test on ubuntu with docker
```bash
# build the image
$ docker build -t ubuntu_test tests# run the image
$ docker run -it -v $PWD:/libkm ubuntu_test
```## π¦ CONTENTS
All the functionality contained in the library!
- [Containers](#-containers)
- [IO](#-io)
- [String](#-string)
- [Memory](#-memory)
- [Sys](#-sys)
- [Additional](#-additional)## π« Containers:
**Vector**
Like in c++ this vector is templated, only you have to register the types yourself using macros
> For a more detailed description of vector check out [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/containers/vector.h)Here is a quick example on how to create a vector of type int
```c++
#include "libkm/containers/vector.h"// put this in the .h
REGISTER_KM_VECTOR_PROTOTYPES(int, integer)// put this in the .c
REGISTER_KM_VECTOR_SOURCE(int, integer)//after registering the vector you can initialise it like this:
km_vector_integer_initialise(&vec, NULL, NULL);// and destroy it like this
km_vector_integer_destroy(&vec);
```## 𧬠IO:
**Printf family**
> For a more detailed description of the printf family check out [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/io/printf.h)
- km_dprintf()
- km_printf()
- km_sprintf()
- km_snprintf()**Get delim**
> For a more detailed description of the getdelim functions check out [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/io/getdelim.h)
- getdelim
- getline## π String:
**Ascii to integral conversions**
> For a more detailed description of the integral conversions check out [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/string.h)
- km_atoi()
- km_atol()
- km_strtoll()
- km_strtol()**String**
> For a more detailed description of the string functions check out [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/string.h#L110)
- km_strlcpy()
- km_strlcat()
- km_toupper()
- km_tolower()
- km_strchr()
- km_strrchr()
- km_strcmp()
- km_strncmp()
- km_strstr()
- km_strnstr()
- km_strcasestr()
- km_strtok()
- km_strdup()
- km_strndup()
- km_strlen()
- km_strnlen()
- km_isupper()
- km_islower()
- km_isalpha()
- km_isdigit()
- km_isascii()
- km_isprint()## π Memory:
> For a more detailed description of the memory functions checkout [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/memory.h)
- km_memmove()
- km_bzero()
- km_calloc()
- km_stupid_realloc()
- km_memchr()
- km_memcmp()
- km_memcpy()
- km_memset()## π½ Sys:
> For a more detailed description of the system functions checkout [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/sys/cacheline.h)
- get_cache_line_size()## β Additional:
**IO**
> For a more detailed description about the additional IO functions checkout [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/additional/io.h)
- km_putchar_fd()
- km_putstr_fd()
- km_putendl_fd()
- km_putnbr_fd()**String**
> For a more detailed description about the additional String functions checkout [this!](https://github.com/K1ngmar/libkm/blob/main/includes/libkm/additional/string.h)
- km_substr()
- km_strjoin()
- km_safe_strjoin()
- km_strtrim()
- km_ltoa()
- km_itoa()
- km_strmapi()
- km_striteri()
- km_split()