Maj du makefile (-Wall) + implémentation de init et push de la pile

This commit is contained in:
Paul Faure 2020-10-01 15:42:11 +02:00
parent 1b24e9c9dc
commit 5075de4acb
2 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
#include "pile.h"
void init(struct pile ** une_pile) {
*une_pile = (struct pile *)malloc(sizeof(struct pile));
}
void push(int e, struct pile * une_pile) {
struct cell * aux;
if (une_pile->taille == 0) {
une_pile->taille = 1;
une_pile->deb = (struct cell *)malloc(sizeof(struct cell));
une_pile->deb->suiv = NULL;
une_pile->deb->val = e;
} else {
une_pile->taille += 1;
aux = une_pile->deb;
une_pile->deb = (struct cell *)malloc(sizeof(struct cell));
une_pile->deb->val = e;
une_pile->deb->suiv = aux;
}
}

View file

@ -15,7 +15,7 @@ forth : forth.o PILE/pile.o LISTE/liste.o LEXER/lexer.o
gcc -Wall LEXER/lexer.o LISTE/liste.o PILE/pile.o forth.o -o forth_interpretor
%.o : %.c
gcc -c $< -o $@
gcc -Wall -c $< -o $@
PILE/pile.o : PILE/pile.h
LISTE/liste.o : LISTE/liste.h