36,7 → 36,6 |
|
#include <errno.h> |
#include <malloc.h> |
#include <stdio.h> |
#include <string.h> |
#include <unistd.h> |
#include <ipc/ipc.h> |
70,14 → 69,17 |
char * next; |
ipc_callid_t callid; |
|
if(( ! strings ) || ( ! data ) || ( count <= 0 )){ |
if(( ! strings ) || ( !( * data )) || ( count <= 0 )){ |
return EINVAL; |
} |
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 )); |
if( ! lengths ) return ENOMEM; |
if(( ! ipc_data_write_receive( & callid, & length )) |
|| ( length != sizeof( size_t ) * ( count + 1 ))){ |
if( ERROR_OCCURED( ipc_data_write_receive( & callid, & length ))){ |
free( lengths ); |
return ERROR_CODE; |
} |
if( length < sizeof( size_t ) * ( count + 1 )){ |
free( lengths ); |
return EINVAL; |
} |
if( ERROR_OCCURED( ipc_data_write_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){ |
86,7 → 88,6 |
} |
* data = malloc( lengths[ count ] ); |
if( !( * data )) return ENOMEM; |
( * data )[ lengths[ count ] - 1 ] = '\0'; |
* strings = ( measured_string_ref ) malloc( sizeof( measured_string_t ) * count ); |
if( !( * strings )){ |
free( lengths ); |
97,8 → 98,8 |
for( index = 0; index < count; ++ index ){ |
( * strings)[ index ].length = lengths[ index ]; |
if( lengths[ index ] > 0 ){ |
if(( ! ipc_data_write_receive( & callid, & length )) |
|| ( length != lengths[ index ] )){ |
ERROR_PROPAGATE( ipc_data_write_receive( & callid, & length )); |
if( length < lengths[ index ] + 1 ){ |
free( * data ); |
free( * strings ); |
free( lengths ); |
105,7 → 106,6 |
return EINVAL; |
} |
ERROR_PROPAGATE( ipc_data_write_finalize( callid, next, lengths[ index ] )); |
( * strings)[ index ].value = next; |
next += lengths[ index ]; |
* next = '\0'; |
++ next; |
130,9 → 130,12 |
} |
lengths = prepare_lengths( strings, count ); |
if( ! lengths ) return ENOMEM; |
if(( ! ipc_data_read_receive( & callid, & length )) |
|| ( length != sizeof( size_t ) * ( count + 1 ))){ |
if( ERROR_OCCURED( ipc_data_read_receive( & callid, & length ))){ |
free( lengths ); |
return ERROR_CODE; |
} |
if( length < strings[ index ].length + 1 ){ |
free( lengths ); |
return EINVAL; |
} |
if( ERROR_OCCURED( ipc_data_read_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){ |
142,8 → 145,8 |
free( lengths ); |
for( index = 0; index < count; ++ index ){ |
if( strings[ index ].length > 0 ){ |
if(( ! ipc_data_read_receive( & callid, & length )) |
|| ( length != strings[ index ].length )){ |
ERROR_PROPAGATE( ipc_data_read_receive( & callid, & length )); |
if( length < strings[ index ].length + 1 ){ |
return EINVAL; |
} |
ERROR_PROPAGATE( ipc_data_read_finalize( callid, strings[ index ].value, strings[ index ].length )); |
159,7 → 162,7 |
int index; |
char * next; |
|
if(( phone <= 0 ) || ( ! strings ) || ( ! data ) || ( count <= 0 )){ |
if(( phone <= 0 ) || ( ! strings ) || ( !( * data )) || ( count <= 0 )){ |
return EINVAL; |
} |
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 )); |
180,8 → 183,8 |
for( index = 0; index < count; ++ index ){ |
( * strings )[ index ].length = lengths[ index ]; |
if( lengths[ index ] > 0 ){ |
( * strings )[ index ].value = next; |
ERROR_PROPAGATE( ipc_data_read_start( phone, next, lengths[ index ] )); |
( * strings )[ index ].value = next; |
next += lengths[ index ]; |
* next = '\0'; |
++ next; |
211,7 → 214,7 |
free( lengths ); |
for( index = 0; index < count; ++ index ){ |
if( strings[ index ].length > 0 ){ |
ERROR_PROPAGATE( ipc_data_write_start( phone, strings[ index ].value, strings[ index ].length )); |
ERROR_PROPAGATE( ipc_data_write_start( phone, strings[ index ].value, strings[ index ].length + 1 )); |
} |
} |
return EOK; |