Skip to content

Commit b4a6f0b

Browse files
authored
valgrind fix
1 parent 1fbd444 commit b4a6f0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+9595
-0
lines changed

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# **************************************************************************** #
2+
# #
3+
# ::: :::::::: #
4+
# Makefile :+: :+: :+: #
5+
# +:+ +:+ +:+ #
6+
# By: jergoh <marvin@42.fr> +#+ +:+ +#+ #
7+
# +#+#+#+#+#+ +#+ #
8+
# Created: 2024/03/18 14:54:03 by jergoh #+# #+# #
9+
# Updated: 2024/03/18 14:54:05 by jergoh ### ########.fr #
10+
# #
11+
# **************************************************************************** #
12+
13+
OBJS_SL = $(SRCS_SL:.c=.o)
14+
SRCS_SL = $(addprefix $(SRC_DIR)/, \
15+
core/main.c core/map.c core/event.c core/move.c \
16+
core/logic.c core/monster_logic.c \
17+
utils/init.c utils/mem.c utils/open_ber.c utils/validate_path.c utils/render.c \
18+
)
19+
20+
SRC_DIR = ./sources
21+
INC_DIR = ./includes/
22+
CC = gcc
23+
MF = Makefile
24+
25+
NAME = so_long
26+
LIBFT_PATH = ./libft/libft.a
27+
SL_HEADER_FILE = $(INC_DIR)/so_long.h
28+
CFLAGS = -Wall -Wextra -Werror
29+
30+
GFLAGS = -lXext -lX11 -lm -lbsd
31+
GPATH = ./mlx/
32+
MLX_PATH = $(GPATH)/libmlx.a
33+
34+
all: $(NAME)
35+
36+
$(NAME): $(MF) $(LIBFT_PATH) $(MLX_PATH) $(OBJS_SL)
37+
@$(CC) $(CFLAGS) $(OBJS_SL) $(LIBFT_PATH) $(MLX_PATH) $(GFLAGS) -o $(NAME)
38+
@echo ""
39+
@printf "\033[1;32m%s\033[0m\n" "[so_long] Compiled successfully."
40+
@cat so_long_splash.txt
41+
42+
%.o: %.c $(SL_HEADER_FILE) $(MF)
43+
@printf "\033[1;32m|\033[0m"
44+
@$(CC) $(CFLAGS) -c $< -o $@ -I $(INC_DIR)
45+
46+
$(LIBFT_PATH): .libft
47+
48+
.libft:
49+
@make -s -C ./libft DEBUG=$(DEBUG)
50+
51+
$(MLX_PATH): .mlx
52+
53+
.mlx:
54+
@make -s -C $(GPATH)
55+
56+
clean:
57+
@make -s clean -C ./libft
58+
@make -s clean -C $(GPATH)
59+
@rm -f $(OBJS_SL)
60+
@printf "\033[1;31m%s\033[0m\n" "[so_long] Object files cleaned."
61+
62+
fclean: clean
63+
@make -s fclean -C ./libft
64+
@make -s clean -C $(GPATH)
65+
@rm -f $(NAME)
66+
@printf "\033[1;31m%s\033[0m\n" "[so_long] Cleaned successfully."
67+
68+
re: fclean all
69+
70+
.PHONY: all clean fclean re

maps/42.ber

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
11111111111111111111111111111111111111111
2+
10M00000000000C00000000000000000000000001
3+
10000000000000000000000000000000000000001
4+
100E0C0000C00M111111100111111111111111001
5+
10000000000000111111100111111111111111001
6+
10000000000111111110000111110011111111001
7+
10000000000111111110000111100011111111001
8+
10000000011111110000000110000011111111001
9+
10000000011111110000000100000011111111001
10+
1000001111111100000C000000000011111110001
11+
10000011111111000000000000000011111110001
12+
10001111111000000M00000000011111111000001
13+
100011111110000000000000000111111110000M1
14+
1001111110000000000M000001111111000000001
15+
1001111110000000000000000111111100M000001
16+
1001111000P0000C0C00000111111100000000001
17+
10011110000000000000000111111100000000001
18+
10011111111111111111100111111100000111001
19+
10011111111111111111100111111100000111001
20+
10011111111111111111100111111100011111001
21+
10011111111111111111100111111100011111001
22+
10000000000000111111100111111101111111001
23+
1000000000000M111111100111111101111111001
24+
10000000C00000111111100000000000000000001
25+
10000000000000111111100000000000000000001
26+
1M00000000000011111110000000000000M000001
27+
100000000000000000000MM0M0000000000000001
28+
11111111111111111111111111111111111111111

maps/map.ber

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
11111111111111111111111111111111111111111
2+
10000000000000C00000000000000000000000001
3+
10000000000000000000000000000000000000001
4+
100E000000C000111111100111111111111111001
5+
10000000000000111111100111111111111111001
6+
10000000000111111110000111110011111111001
7+
10000000000111111110000111100011111111001
8+
10000000011111110000000110000011111111001
9+
10000000011111110000000100000011111111001
10+
1000001111111100000C000000000011111110001
11+
10000011111111000000000000000011111110001
12+
10001111111000000000000000011111111000001
13+
10001111111000000000000000011111111000001
14+
10011111100000000000000001111111000000001
15+
10011111100000000000000001111111000000001
16+
1001111000P0000C0C00000111111100000000001
17+
10011110000000000000000111111100000000001
18+
10011111111111111111100111111100000111001
19+
10011111111111111111100111111100000111001
20+
10011111111111111111100111111100011111001
21+
10011111111111111111100111111100011111001
22+
10000000000000111111100111111101111111001
23+
10000000000000111111100111111101111111001
24+
10000000C00000111111100000000000000000001
25+
10000000000000111111100000000000000000001
26+
10000000000000111111100000000000000000001
27+
10000000000000000000000000000000000000001
28+
11111111111111111111111111111111111111111

maps/test.ber

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
111111
2+
100001
3+
100001C
4+
111111

mlx/LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2021, Ecole 42
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

mlx/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
##
2+
## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx
3+
##
4+
## Made by Olivier Crouzet
5+
## Login <ol@epitech.net>
6+
##
7+
## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet
8+
## Last update Tue May 15 15:44:41 2007 Olivier Crouzet
9+
##
10+
11+
## Please use configure script
12+
13+
all : do_configure
14+
15+
do_configure :
16+
./configure
17+
18+
clean :
19+
./configure clean
20+
21+
re : clean all

mlx/Makefile.gen

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
INC=/usr/include
2+
##
3+
## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx
4+
##
5+
## Made by Olivier Crouzet
6+
## Login <ol@epitech.net>
7+
##
8+
## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet
9+
## Last update Tue May 15 15:41:20 2007 Olivier Crouzet
10+
##
11+
12+
## Please use configure script
13+
14+
15+
16+
UNAME = $(shell uname)
17+
CC = gcc
18+
ifeq ($(UNAME),FreeBSD)
19+
CC = clang
20+
endif
21+
22+
NAME = libmlx.a
23+
NAME_UNAME = libmlx_$(UNAME).a
24+
25+
SRC = mlx_init.c mlx_new_window.c mlx_pixel_put.c mlx_loop.c \
26+
mlx_mouse_hook.c mlx_key_hook.c mlx_expose_hook.c mlx_loop_hook.c \
27+
mlx_int_anti_resize_win.c mlx_int_do_nothing.c \
28+
mlx_int_wait_first_expose.c mlx_int_get_visual.c \
29+
mlx_flush_event.c mlx_string_put.c mlx_set_font.c \
30+
mlx_new_image.c mlx_get_data_addr.c \
31+
mlx_put_image_to_window.c mlx_get_color_value.c mlx_clear_window.c \
32+
mlx_xpm.c mlx_int_str_to_wordtab.c mlx_destroy_window.c \
33+
mlx_int_param_event.c mlx_int_set_win_event_mask.c mlx_hook.c \
34+
mlx_rgb.c mlx_destroy_image.c mlx_mouse.c mlx_screen_size.c \
35+
mlx_destroy_display.c
36+
37+
OBJ_DIR = obj
38+
OBJ = $(addprefix $(OBJ_DIR)/,$(SRC:%.c=%.o))
39+
CFLAGS = -O3 -I$(INC)
40+
41+
all : $(NAME)
42+
43+
$(OBJ_DIR)/%.o: %.c
44+
@mkdir -p $(OBJ_DIR)
45+
@printf "\033[1;33m|\033[0m"
46+
$(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@
47+
48+
$(NAME) : $(OBJ)
49+
ar -r $(NAME) $(OBJ) >/dev/null 2>&1
50+
ranlib $(NAME)
51+
cp $(NAME) $(NAME_UNAME)
52+
@echo ""
53+
@printf "\033[1;33m%s\033[0m\n" "[minilibx] Compiled successfully."
54+
55+
check: all
56+
@test/run_tests.sh
57+
58+
show:
59+
@printf "NAME : $(NAME)\n"
60+
@printf "NAME_UNAME : $(NAME_UNAME)\n"
61+
@printf "CC : $(CC)\n"
62+
@printf "CFLAGS : $(CFLAGS)\n"
63+
@printf "SRC :\n $(SRC)\n"
64+
@printf "OBJ :\n $(OBJ)\n"
65+
66+
clean :
67+
rm -rf $(OBJ_DIR)/ $(NAME) $(NAME_UNAME) *~ core *.core
68+
@printf "\033[1;31m%s\033[0m\n" "[minilibx] Object files cleaned."
69+
70+
.PHONY: all check show clean

mlx/Makefile.mk

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
##
2+
## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx
3+
##
4+
## Made by Olivier Crouzet
5+
## Login <ol@epitech.net>
6+
##
7+
## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet
8+
## Last update Tue May 15 15:41:20 2007 Olivier Crouzet
9+
##
10+
11+
## Please use configure script
12+
13+
14+
INC =%%%%
15+
16+
UNAME = $(shell uname)
17+
CC = gcc
18+
ifeq ($(UNAME),FreeBSD)
19+
CC = clang
20+
endif
21+
22+
NAME = libmlx.a
23+
NAME_UNAME = libmlx_$(UNAME).a
24+
25+
SRC = mlx_init.c mlx_new_window.c mlx_pixel_put.c mlx_loop.c \
26+
mlx_mouse_hook.c mlx_key_hook.c mlx_expose_hook.c mlx_loop_hook.c \
27+
mlx_int_anti_resize_win.c mlx_int_do_nothing.c \
28+
mlx_int_wait_first_expose.c mlx_int_get_visual.c \
29+
mlx_flush_event.c mlx_string_put.c mlx_set_font.c \
30+
mlx_new_image.c mlx_get_data_addr.c \
31+
mlx_put_image_to_window.c mlx_get_color_value.c mlx_clear_window.c \
32+
mlx_xpm.c mlx_int_str_to_wordtab.c mlx_destroy_window.c \
33+
mlx_int_param_event.c mlx_int_set_win_event_mask.c mlx_hook.c \
34+
mlx_rgb.c mlx_destroy_image.c mlx_mouse.c mlx_screen_size.c \
35+
mlx_destroy_display.c
36+
37+
OBJ_DIR = obj
38+
OBJ = $(addprefix $(OBJ_DIR)/,$(SRC:%.c=%.o))
39+
CFLAGS = -O3 -I$(INC)
40+
41+
all : $(NAME)
42+
43+
$(OBJ_DIR)/%.o: %.c
44+
@mkdir -p $(OBJ_DIR)
45+
@printf "\033[1;33m|\033[0m"
46+
$(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@
47+
48+
$(NAME) : $(OBJ)
49+
ar -r $(NAME) $(OBJ) >/dev/null 2>&1
50+
ranlib $(NAME)
51+
cp $(NAME) $(NAME_UNAME)
52+
@echo ""
53+
@printf "\033[1;33m%s\033[0m\n" "[minilibx] Compiled successfully."
54+
55+
check: all
56+
@test/run_tests.sh
57+
58+
show:
59+
@printf "NAME : $(NAME)\n"
60+
@printf "NAME_UNAME : $(NAME_UNAME)\n"
61+
@printf "CC : $(CC)\n"
62+
@printf "CFLAGS : $(CFLAGS)\n"
63+
@printf "SRC :\n $(SRC)\n"
64+
@printf "OBJ :\n $(OBJ)\n"
65+
66+
clean :
67+
rm -rf $(OBJ_DIR)/ $(NAME) $(NAME_UNAME) *~ core *.core
68+
@printf "\033[1;31m%s\033[0m\n" "[minilibx] Object files cleaned."
69+
70+
.PHONY: all check show clean

mlx/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[![Build](https://github.com/42Paris/minilibx-linux/actions/workflows/ci.yml/badge.svg)](https://github.com/42Paris/minilibx-linux/actions/workflows/ci.yml)
2+
3+
This is the MinilibX, a simple X-Window (X11R6) programming API
4+
in C, designed for students, suitable for X-beginners.
5+
6+
7+
Contents
8+
9+
- source code in C to create the mlx library
10+
- man pages (in man/ directory)
11+
- a test program (in test/ directory) is built
12+
with the library
13+
- a public include file mlx.h
14+
- a tiny configure script to generate an appropriate Makefile.gen
15+
16+
Requirements for Linux
17+
18+
- MinilibX only support TrueColor visual type (8,15,16,24 or 32 bits depth)
19+
- gcc
20+
- make
21+
- X11 include files (package xorg)
22+
- XShm extension must be present (package libxext-dev)
23+
- Utility functions from BSD systems - development files (package libbsd-dev)
24+
- **e.g. _sudo apt-get install gcc make xorg libxext-dev libbsd-dev_ (Debian/Ubuntu)**
25+
26+
Requirements for MacOS
27+
- [Xquartz](https://www.xquartz.org/)
28+
29+
```bash
30+
~ Brew install Xquartz
31+
~ reboot
32+
~ xeyes # run an hello world X11 app
33+
```
34+
35+
MlX Color Opacity / Transparency / Alpha (32 bits depth)
36+
- 0xFF (fully transparent) or 0x00 (fully opaque)
37+
38+
Compile MinilibX
39+
40+
- run ./configure or make
41+
both will make a few tests, create Makefile.gen
42+
and then automatically run make on this generated Makefile.gen .
43+
libmlx.a and libmlx_$(HOSTTYPE).a are created.
44+
test/mlx-test binary is also created.
45+
46+
47+
Install MinilibX
48+
49+
- no installation script is provided. You may want to install
50+
- libmlx.a and/or libmlx_$(HOSTTYPE).a in /usr/X11/lib or /usr/local/lib
51+
- mlx.h in /usr/X11/include or /usr/local/include
52+
- man/man3/mlx*.1 in /usr/X11/man/man3 or /usr/local/man/man3
53+
54+
55+
Olivier CROUZET - 2014-01-06 -

0 commit comments

Comments
 (0)