mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-23 15:16:26 +01:00
Fix various memory leaks
This commit is contained in:
parent
2ac811ca78
commit
b6aafbf0fd
2
Makefile
2
Makefile
@ -35,6 +35,8 @@ NVCCFLAGS +=
|
||||
# -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable
|
||||
# Compile with debug
|
||||
# -g
|
||||
# See memory leaks and Incorrect Read/Write
|
||||
# -fsanitize=address -lasan
|
||||
|
||||
all: mnist cnn;
|
||||
#
|
||||
|
@ -203,9 +203,7 @@ void free_dataset(jpegDataset* dataset) {
|
||||
}
|
||||
free(dataset->fileNames);
|
||||
free(dataset->labels);
|
||||
#ifdef STORE_IMAGES_TO_RAM
|
||||
free(dataset->images);
|
||||
#endif
|
||||
free(dataset);
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,7 @@ void print_weights(char* filename) {
|
||||
|
||||
void count_labels(char* filename) {
|
||||
uint32_t number_of_images = read_mnist_labels_nb_images(filename);
|
||||
|
||||
unsigned int* labels = (unsigned int*)malloc(sizeof(unsigned int)*number_of_images);
|
||||
labels = read_mnist_labels(filename);
|
||||
unsigned int* labels = read_mnist_labels(filename);
|
||||
|
||||
unsigned int tab[10];
|
||||
|
||||
|
@ -49,5 +49,14 @@ int main() {
|
||||
read_test(nb_images, width, height, images, labels);
|
||||
|
||||
printf(GREEN "OK\n" RESET);
|
||||
for (int i=0; i < nb_images; i++) {
|
||||
for (int j=0; j < height; j++) {
|
||||
free(images[i][j]);
|
||||
}
|
||||
free(images[i]);
|
||||
}
|
||||
free(images);
|
||||
free(labels);
|
||||
free(parameters);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user