summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2025-02-18 11:52:36 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2025-02-18 11:52:36 +0100
commit0f8b7379641f94dcd22c6a299cf4d62588838083 (patch)
tree15e282d0bb65896d7b8f88ef19c02bc4610abc5e
parent57a744d7e0a4aeda1ba0f346af4cae9be5ee15e8 (diff)
was freeing a pointer before i used it for its purpose what made some things mall function
-rw-r--r--.DS_Storebin0 -> 6148 bytes
-rwxr-xr-xa.outbin0 -> 34088 bytes
-rw-r--r--cmake-build-debug/Testing/Temporary/LastTest.log4
-rwxr-xr-xmainbin18744 -> 34088 bytes
-rw-r--r--main.c19
5 files changed, 9 insertions, 14 deletions
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..d41ba46
--- /dev/null
+++ b/.DS_Store
Binary files differ
diff --git a/a.out b/a.out
new file mode 100755
index 0000000..8f1b87b
--- /dev/null
+++ b/a.out
Binary files differ
diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log
index f9dd9c3..b107cce 100644
--- a/cmake-build-debug/Testing/Temporary/LastTest.log
+++ b/cmake-build-debug/Testing/Temporary/LastTest.log
@@ -1,3 +1,3 @@
-Start testing: Feb 17 21:55 CET
+Start testing: Feb 18 10:45 CET
----------------------------------------------------------
-End testing: Feb 17 21:55 CET
+End testing: Feb 18 10:45 CET
diff --git a/main b/main
index 8242578..9e7e6f9 100755
--- a/main
+++ b/main
Binary files differ
diff --git a/main.c b/main.c
index e8decd9..42a1894 100644
--- a/main.c
+++ b/main.c
@@ -17,11 +17,6 @@ void test() {
printf("\nprint to output");
}
-// exit() command
-void exit_() {
- exit(0);
-}
-
// ls command
// get the requested path and put it into a const later on when getting the user input
@@ -80,18 +75,18 @@ int main(void) {
if (strcmp(new_input.com, "exit\n") == 0) {
- exit_();
- free(input);
- free(new_input.com);
- free(new_input.arg);
+ if (input != NULL)
+ free(input);
+ if (new_input.com != NULL)
+ free(new_input.com);
+ if (new_input.arg != NULL)
+ free(new_input.arg);
return 0;
}
if (strcmp(new_input.com, "ls\n") == 0) {
- printf("DETECTED LS COMMAND");
- printf("\nARGUMENT NOT DEFINED");
+ ls(new_input.arg);
free(new_input.com);
free(new_input.arg);
- ls(new_input.arg);
}
if (strcmp(new_input.com, "echo\n") == 0) {
printf("DETECTED ECHO COMMAND");