}
}
-char* get_detail_info( int qemu_argc, char** qemu_argv ) {
+DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
- int i;
- int total_len = 0;
+ DetailInfo* detail_info = g_malloc0( sizeof(DetailInfo) );
+ if ( !detail_info ) {
+ ERR( "Fail to malloc for DetailInfo.\n" );
+ return NULL;
+ }
+ int i = 0;
+ int total_len = 0;
int delimiter_len = strlen( DATA_DELIMITER );
for ( i = 0; i < qemu_argc; i++ ) {
}
char* info_data = g_malloc0( total_len );
+ if ( !info_data ) {
+ g_free( detail_info );
+ ERR( "Fail to malloc for info data.\n" );
+ return NULL;
+ }
int len = 0;
total_len = 0;
- for ( i = 0; i < qemu_argc; ++i ) {
+ for ( i = 0; i < qemu_argc; i++ ) {
len = strlen( qemu_argv[i] );
sprintf( info_data + total_len, "%s", qemu_argv[i] );
}
- return info_data;
+ detail_info->data = info_data;
+ detail_info->data_length = total_len;
+
+ return detail_info;
}
-void free_detail_info( char* detail_info ) {
+void free_detail_info( DetailInfo* detail_info ) {
if ( detail_info ) {
+ if ( detail_info->data ) {
+ g_free( detail_info->data );
+ }
g_free( detail_info );
}
}
};
typedef struct QemuSurfaceInfo QemuSurfaceInfo;
+struct DetailInfo {
+ char* data;
+ int data_length;
+};
+typedef struct DetailInfo DetailInfo;
+
void start_display( int handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short rotation_type );
void do_mouse_event( int event_type, int x, int y, int z );
QemuSurfaceInfo* get_screenshot_info( void );
-char* get_detail_info( int qemu_argc, char** qemu_argv );
+DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv );
-void free_detail_info( char* detail_info );
+void free_detail_info( DetailInfo* detail_info );
void free_screenshot_info( QemuSurfaceInfo* );
log_cnt += sprintf( log_buf + log_cnt, "RECV_DETAIL_INFO ==\n" );
TRACE( log_buf );
- char* info_data = get_detail_info( qmu_argc, qmu_argv );
- int len = strlen( info_data );
- send_skin_data( client_sock, SEND_DETAIL_INFO, (unsigned char*)info_data, len, 0 );
- free_detail_info( info_data );
+ DetailInfo* detail_info = get_detail_info( qmu_argc, qmu_argv );
+
+ if ( detail_info ) {
+ send_skin_data( client_sock, SEND_DETAIL_INFO, (unsigned char*) detail_info->data,
+ detail_info->data_length, 0 );
+ free_detail_info( detail_info );
+ } else {
+ ERR( "Fail to get detail info.\n" );
+ }
+
break;
}
case RECV_RESPONSE_HEART_BEAT: {