init
This commit is contained in:
commit
4b5ee8bf10
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra -Werror
|
||||
|
||||
NAME = bozolib
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
SOURCES = $(shell find $(SRC_DIR) -type f -name '*.c')
|
||||
OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SOURCES))
|
||||
DEPS = $(OBJECTS:.o=.d)
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(OBJECTS)
|
||||
ar -rc $(NAME) $(OBJECTS)
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR)
|
||||
|
||||
fclean: clean
|
||||
rm -f $(NAME)
|
||||
|
||||
re: fclean $(NAME)
|
14
src/lst/lst.h
Normal file
14
src/lst/lst.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct s_lst
|
||||
{
|
||||
void* content;
|
||||
struct s_lst* next;
|
||||
} lst;
|
||||
|
||||
size_t lst_len(const lst* root);
|
||||
void lst_iter(const lst* root, void (*f)(void *));
|
||||
lst* lst_find(lst* root, void (*cmp)(const lst* lst1, const lst* lst2));
|
||||
void lst_addback(lst** root, lst* nouveau);
|
||||
void lst_clear(lst** root, void (*del)(void *));
|
14
src/lst/lst_len.c
Normal file
14
src/lst/lst_len.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stddef.h>
|
||||
#include "./lst.h"
|
||||
|
||||
size_t lst_len(const lst* root)
|
||||
{
|
||||
size_t i = 0;
|
||||
const lst *current = root;
|
||||
while (current != NULL)
|
||||
{
|
||||
current = current->next;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
Loading…
Reference in New Issue
Block a user