From 825a844fdcfd4532cddde14d7bb38f1f981fa9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 6 Sep 2022 18:39:07 +0300 Subject: ld: pe: Apply review suggestions on the existing exports/imports arrays Use a separate explicit max_exports/imports field, instead of deducing it from the number of allocated elements. Use a named constant for the incremental growth of the array. Use bool instead of int for boolean values. Remove an unnecessary if statement/scope in the def_file_free function. Add more verbose comments about parameters, and about insertion into an array of structs. Generally use unsigned integers for all array indices and sizes. The num_exports/imports fields are kept as is as signed integers, since changing them to unsigned would require a disproportionate amount of changes ti pe-dll.c to avoid comparisons between signed and unsigned. Simply use xrealloc instead of a check and xmalloc/xrealloc; xrealloc can take NULL as the first parameter (and does a similar check internally). (This wasn't requested in review though, but noticed while working on the code.) --- ld/deffile.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ld/deffile.h') diff --git a/ld/deffile.h b/ld/deffile.h index 89ffe9f..9eb08ad 100644 --- a/ld/deffile.h +++ b/ld/deffile.h @@ -84,6 +84,7 @@ typedef struct def_file { /* From the EXPORTS commands. */ int num_exports; + unsigned int max_exports; def_file_export *exports; /* Used by imports for module names. */ @@ -91,6 +92,7 @@ typedef struct def_file { /* From the IMPORTS commands. */ int num_imports; + unsigned int max_imports; def_file_import *imports; /* From the VERSION command, -1 if not specified. */ @@ -112,10 +114,10 @@ extern def_file *def_file_parse (const char *, def_file *); extern void def_file_free (def_file *); extern def_file_export *def_file_add_export (def_file *, const char *, const char *, int, - const char *, int *); + const char *, bool *); extern def_file_import *def_file_add_import (def_file *, const char *, const char *, int, const char *, - const char *, int *); + const char *, bool *); extern int def_file_add_import_from (def_file *fdef, int num_imports, const char *name, -- cgit v1.1