From 4166e88f9285307690244d1b0447d1feb9795ad6 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 23 Jan 2020 15:54:24 -0500 Subject: [PATCH] Use compound literals. --- platform-independent/c/core/src/mpw-marshal.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/platform-independent/c/core/src/mpw-marshal.c b/platform-independent/c/core/src/mpw-marshal.c index 4b11f2a0..7f20841a 100644 --- a/platform-independent/c/core/src/mpw-marshal.c +++ b/platform-independent/c/core/src/mpw-marshal.c @@ -934,17 +934,21 @@ int mpw_marshal_format_extensions( break; } case MPMarshalFormatFlat: { - const char *array[3] = { mpw_marshal_format_extension( format ), "mpsites.txt", "txt" }; - count = sizeof( array ) / sizeof( *array ); - *extensions = realloc( *extensions, count * sizeof( const char * ) ); - memcpy( *extensions, array, count * sizeof( const char * ) ); + *extensions = realloc( *extensions, (count = 3) * sizeof( const char * ) ); + memcpy( *extensions, (const char *[]){ + mpw_marshal_format_extension( format ), + "mpsites.txt", + "txt", + }, count * sizeof( const char * ) ); break; } case MPMarshalFormatJSON: { - const char *array[3] = { mpw_marshal_format_extension( format ), "mpsites.json", "json" }; - count = sizeof( array ) / sizeof( *array ); - *extensions = realloc( *extensions, sizeof( array ) ); - memcpy( *extensions, array, sizeof( array ) ); + *extensions = realloc( *extensions, (count = 3) * sizeof( const char * ) ); + memcpy( *extensions, (const char *[]){ + mpw_marshal_format_extension( format ), + "mpsites.json", + "json", + }, count * sizeof( const char * ) ); break; } default: {