From 9c76808b893c028259f5dee0abbc016bd083d5d6 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 2 Nov 2003 20:39:26 +0000 Subject: [PATCH] (alloc_and_compile_regex, main): Use `sizeof *var' rather than `sizeof EXPLICIT_TYPE'. The former is more maintainable and usually shorter. --- src/ptx.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/ptx.c b/src/ptx.c index f34db72e51..1ba12e197f 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -394,8 +394,7 @@ alloc_and_compile_regex (const char *string) struct re_pattern_buffer *pattern; /* newly allocated structure */ const char *message; /* error message returned by regex.c */ - pattern = (struct re_pattern_buffer *) - xmalloc (sizeof (struct re_pattern_buffer)); + pattern = xmalloc (sizeof *pattern); memset (pattern, 0, sizeof (struct re_pattern_buffer)); pattern->buffer = NULL; @@ -2107,18 +2106,16 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"), /* No more argument simply means: read standard input. */ - input_file_name = xmalloc (sizeof (const char *)); - file_line_count = xmalloc (sizeof (int)); + input_file_name = xmalloc (sizeof *input_file_name); + file_line_count = xmalloc (sizeof *file_line_count); number_input_files = 1; input_file_name[0] = NULL; } else if (gnu_extensions) { number_input_files = argc - optind; - input_file_name - = xmalloc (number_input_files * sizeof (const char *)); - file_line_count - = xmalloc (number_input_files * sizeof (int)); + input_file_name = xmalloc (number_input_files * sizeof *input_file_name); + file_line_count = xmalloc (number_input_files * sizeof *file_line_count); for (file_index = 0; file_index < number_input_files; file_index++) { @@ -2136,8 +2133,8 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"), /* There is one necessary input file. */ number_input_files = 1; - input_file_name = xmalloc (sizeof (const char *)); - file_line_count = xmalloc (sizeof (int)); + input_file_name = xmalloc (sizeof *input_file_name); + file_line_count = xmalloc (sizeof *file_line_count); if (!*argv[optind] || strcmp (argv[optind], "-") == 0) input_file_name[0] = NULL; else -- 2.47.2