[Title] modify a logic getting detail info
authorSon Hyunjun <hj79.son@samsung.com>
Fri, 30 Mar 2012 13:25:29 +0000 (22:25 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Fri, 30 Mar 2012 13:25:29 +0000 (22:25 +0900)
[Type] Enhancement
[Module] Skin
[Priority] Minor
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: Idf896224c1a1d8e0ee4cbe41bc2ab0119dc4bc7e

tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c

index 826baa2..09ee363 100644 (file)
@@ -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 );
     }
 }
index b9c771a..a382637 100644 (file)
@@ -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* );
 
index d5706b2..d818126 100644 (file)
@@ -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: {