From 0e951a0f8831ac2885fe64531438eb28202f6e53 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Mon, 13 Nov 2023 05:30:27 +0100 Subject: Move to Chromium styleguide --- file.c | 76 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 0c8a93f..1909946 100644 --- a/file.c +++ b/file.c @@ -3,42 +3,42 @@ #include "file.h" -struct FileContent read_entire_file(const char *file_path) { - struct FileContent file_data; - file_data.content = NULL; - file_data.count = 0; - - FILE *file = fopen(file_path, "rb"); - if (file == NULL) { - perror("Error opening file"); - return file_data; - } - - fseek(file, 0, SEEK_END); - long file_size = ftell(file); - fseek(file, 0, SEEK_SET); - - if (file_size == -1) { - perror("Error getting file size"); - return file_data; - } - - file_data.content = (const char *)malloc(file_size); - if (file_data.content == NULL) { - perror("Error allocating memory"); - return file_data; - } - - size_t bytes_read = fread((void *)file_data.content, 1, file_size, file); - if (bytes_read != (size_t)file_size) { - perror("Error reading file"); - free((void *)file_data.content); - file_data.content = NULL; - return file_data; - } - - file_data.count = bytes_read; - - fclose(file); - return file_data; +struct FileContent read_entire_file(const char* file_path) { + struct FileContent file_data; + file_data.content = NULL; + file_data.count = 0; + + FILE* file = fopen(file_path, "rb"); + if (file == NULL) { + perror("Error opening file"); + return file_data; + } + + fseek(file, 0, SEEK_END); + long file_size = ftell(file); + fseek(file, 0, SEEK_SET); + + if (file_size == -1) { + perror("Error getting file size"); + return file_data; + } + + file_data.content = (const char*)malloc(file_size); + if (file_data.content == NULL) { + perror("Error allocating memory"); + return file_data; + } + + size_t bytes_read = fread((void*)file_data.content, 1, file_size, file); + if (bytes_read != (size_t)file_size) { + perror("Error reading file"); + free((void*)file_data.content); + file_data.content = NULL; + return file_data; + } + + file_data.count = bytes_read; + + fclose(file); + return file_data; } -- cgit v1.2.3