2
0

Change marshal API to return output directly.

Avoids an ambiguity between return type and out value (eg. true but
NULL), and improves Swift API access.
This commit is contained in:
Maarten Billemont
2020-01-23 15:59:21 -05:00
parent f0acd1fed1
commit 6d36f17e57
4 changed files with 64 additions and 56 deletions

View File

@@ -806,9 +806,9 @@ void cli_save(Arguments *args, Operation *operation) {
return;
}
char *buf = NULL;
MPMarshalError marshalError = { .type = MPMarshalSuccess };
if (!mpw_marshal_write( &buf, operation->sitesFormat, operation->user, &marshalError ) || marshalError.type != MPMarshalSuccess || !buf)
const char *buf = mpw_marshal_write( operation->sitesFormat, operation->user, &marshalError );
if (!buf || marshalError.type != MPMarshalSuccess)
wrn( "Couldn't encode updated configuration file:\n %s: %s", operation->sitesPath, marshalError.description );
else if (fwrite( buf, sizeof( char ), strlen( buf ), sitesFile ) != strlen( buf ))