From a57d44a64bdae4d82c5cd940254e0c45019fc887 Mon Sep 17 00:00:00 2001 From: Son Hyunjun Date: Fri, 30 Mar 2012 22:25:29 +0900 Subject: [PATCH] [Title] modify a logic getting detail info [Type] Enhancement [Module] Skin [Priority] Minor [CQ#] [Redmine#] [Problem] [Cause] [Solution] Change-Id: Idf896224c1a1d8e0ee4cbe41bc2ab0119dc4bc7e --- tizen/src/skin/maruskin_operation.c | 28 ++++++++++++++++++++++------ tizen/src/skin/maruskin_operation.h | 10 ++++++++-- tizen/src/skin/maruskin_server.c | 14 ++++++++++---- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 826baa2a6c..09ee3639b2 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -261,11 +261,16 @@ void free_screenshot_info( QemuSurfaceInfo* info ) { } } -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++ ) { @@ -274,11 +279,16 @@ char* get_detail_info( int qemu_argc, char** qemu_argv ) { } 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] ); @@ -289,12 +299,18 @@ char* get_detail_info( int qemu_argc, char** qemu_argv ) { } - 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 ); } } diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index b9c771ac3c..a38263767e 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -36,6 +36,12 @@ struct QemuSurfaceInfo { }; 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 ); @@ -50,9 +56,9 @@ void do_rotation_event( int rotation_type ); 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* ); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index d5706b29ce..d818126112 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -543,10 +543,16 @@ static void* run_skin_server( void* args ) { 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: { -- 2.34.1