Use const pointers when possible

This commit is contained in:
apio 2022-11-21 17:38:08 +01:00
parent 1633012823
commit 2aed955e94
2 changed files with 6 additions and 6 deletions

View File

@ -6,9 +6,9 @@
// all of these are defined in util.c // all of these are defined in util.c
int minitar_read_header(struct minitar*, struct tar_header*); int minitar_read_header(struct minitar*, struct tar_header*);
int minitar_validate_header(struct tar_header*); int minitar_validate_header(const struct tar_header*);
void minitar_parse_tar_header(struct tar_header*, struct minitar_entry_metadata*); void minitar_parse_tar_header(const struct tar_header*, struct minitar_entry_metadata*);
struct minitar_entry* minitar_dup_entry(struct minitar_entry*); struct minitar_entry* minitar_dup_entry(const struct minitar_entry*);
char* minitar_read_file_contents(struct minitar_entry_metadata*, struct minitar*); char* minitar_read_file_contents(struct minitar_entry_metadata*, struct minitar*);
struct minitar* minitar_open(const char* pathname) struct minitar* minitar_open(const char* pathname)

View File

@ -18,7 +18,7 @@ noreturn void minitar_panic(const char* message)
minitar_handle_panic(message); minitar_handle_panic(message);
} }
void minitar_parse_tar_header(struct tar_header* hdr, struct minitar_entry_metadata* metadata) void minitar_parse_tar_header(const struct tar_header* hdr, struct minitar_entry_metadata* metadata)
{ {
if (!strlen(hdr->prefix)) if (!strlen(hdr->prefix))
{ {
@ -64,7 +64,7 @@ void minitar_parse_tar_header(struct tar_header* hdr, struct minitar_entry_metad
strcpy(metadata->gname, hdr->gname); strcpy(metadata->gname, hdr->gname);
} }
int minitar_validate_header(struct tar_header* hdr) int minitar_validate_header(const struct tar_header* hdr)
{ {
if (hdr->typeflag != '\0' && hdr->typeflag != '0' && hdr->typeflag != '1' && hdr->typeflag != '2' && if (hdr->typeflag != '\0' && hdr->typeflag != '0' && hdr->typeflag != '1' && hdr->typeflag != '2' &&
hdr->typeflag != '3' && hdr->typeflag != '4' && hdr->typeflag != '5' && hdr->typeflag != '6') hdr->typeflag != '3' && hdr->typeflag != '4' && hdr->typeflag != '5' && hdr->typeflag != '6')
@ -81,7 +81,7 @@ int minitar_read_header(struct minitar* mp, struct tar_header* hdr)
return 1; return 1;
} }
struct minitar_entry* minitar_dup_entry(struct minitar_entry* original) struct minitar_entry* minitar_dup_entry(const struct minitar_entry* original)
{ {
struct minitar_entry* new = malloc(sizeof *original); struct minitar_entry* new = malloc(sizeof *original);
if (!new) return NULL; if (!new) return NULL;