2
0

Use compound literals.

This commit is contained in:
Maarten Billemont 2020-01-23 15:54:24 -05:00
parent 4b73508292
commit 4166e88f92

View File

@ -934,17 +934,21 @@ int mpw_marshal_format_extensions(
break; break;
} }
case MPMarshalFormatFlat: { case MPMarshalFormatFlat: {
const char *array[3] = { mpw_marshal_format_extension( format ), "mpsites.txt", "txt" }; *extensions = realloc( *extensions, (count = 3) * sizeof( const char * ) );
count = sizeof( array ) / sizeof( *array ); memcpy( *extensions, (const char *[]){
*extensions = realloc( *extensions, count * sizeof( const char * ) ); mpw_marshal_format_extension( format ),
memcpy( *extensions, array, count * sizeof( const char * ) ); "mpsites.txt",
"txt",
}, count * sizeof( const char * ) );
break; break;
} }
case MPMarshalFormatJSON: { case MPMarshalFormatJSON: {
const char *array[3] = { mpw_marshal_format_extension( format ), "mpsites.json", "json" }; *extensions = realloc( *extensions, (count = 3) * sizeof( const char * ) );
count = sizeof( array ) / sizeof( *array ); memcpy( *extensions, (const char *[]){
*extensions = realloc( *extensions, sizeof( array ) ); mpw_marshal_format_extension( format ),
memcpy( *extensions, array, sizeof( array ) ); "mpsites.json",
"json",
}, count * sizeof( const char * ) );
break; break;
} }
default: { default: {