Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CC = gcc
CFLAGS = -Wall -Wextra -g -std=c99
TARGET = memory_demo
SOURCE = main.c

all: $(TARGET)

$(TARGET): $(SOURCE)
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE)

valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(TARGET)

valgrind-simple: $(TARGET)
valgrind --tool=memcheck --leak-check=yes ./$(TARGET)

clean:
rm -f $(TARGET)

.PHONY: all debug valgrind valgrind-simple clean

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# ParallelPrograming
using this rep for assingments
# ParallelPrograming
using this rep for assingments
rator. Stop.


student@itcenter-lab128:~/Desktop/parallel programing$ cat -A Makefile
CC = gcc$
Expand Down
36 changes: 36 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
int ipos = 1, ival;
int *iarray = (int *) malloc(10 * sizeof(int));

if (iarray == NULL) {
printf("Memory allocation failed!\n");
return 1;
}

if (argc == 2) {
ival = atoi(argv[1]);
}

for (int i = 0; i < 10; i++) {
iarray[i] = ipos;
}

for (int i = 0; i < 10; i++) {
if (ival == iarray[i]) {
ipos = i;
}
}

if (ipos != 1) {
printf("Found ival at index %d\n", ipos);
} else {
printf("Value %d not found in array.\n", ival);
}

free(iarray);

return 0;
}
21 changes: 21 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CC = gcc
CFLAGS = -Wall -Wextra -g -std=c99
TARGET = memory_demo
SOURCE = main.c

all: $(TARGET)

$(TARGET): $(SOURCE)
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE)

valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(TARGET)

valgrind-simple: $(TARGET)
valgrind --tool=memcheck --leak-check=yes ./$(TARGET)

clean:
rm -f $(TARGET)

.PHONY: all debug valgrind valgrind-simple clean

Binary file added memory_demo
Binary file not shown.