Buildbreak fix in pkgmgr-info.c
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgr-info-basic.c
1
2 #include <stdlib.h>
3
4 #include "pkgmgr-info-basic.h"
5 #include "pkgmgr-info-internal.h"
6
7 static void __ps_free_category(category_x *category)
8 {
9         if (category == NULL)
10                 return;
11         if (category->name) {
12                 free((void *)category->name);
13                 category->name = NULL;
14         }
15         free((void*)category);
16         category = NULL;
17 }
18
19 static void __ps_free_privilege(privilege_x *privilege)
20 {
21         if (privilege == NULL)
22                 return;
23         if (privilege->text) {
24                 free((void *)privilege->text);
25                 privilege->text = NULL;
26         }
27         free((void*)privilege);
28         privilege = NULL;
29 }
30
31 static void __ps_free_privileges(privileges_x *privileges)
32 {
33         if (privileges == NULL)
34                 return;
35         /*Free Privilege*/
36         if (privileges->privilege) {
37                 privilege_x *privilege = privileges->privilege;
38                 privilege_x *tmp = NULL;
39                 while(privilege != NULL) {
40                         tmp = privilege->next;
41                         __ps_free_privilege(privilege);
42                         privilege = tmp;
43                 }
44         }
45         free((void*)privileges);
46         privileges = NULL;
47 }
48
49 static void __ps_free_metadata(metadata_x *metadata)
50 {
51         if (metadata == NULL)
52                 return;
53         if (metadata->key) {
54                 free((void *)metadata->key);
55                 metadata->key = NULL;
56         }
57         if (metadata->value) {
58                 free((void *)metadata->value);
59                 metadata->value = NULL;
60         }
61         free((void*)metadata);
62         metadata = NULL;
63 }
64
65 static void __ps_free_permission(permission_x *permission)
66 {
67         if (permission == NULL)
68                 return;
69         if (permission->type) {
70                 free((void *)permission->type);
71                 permission->type = NULL;
72         }
73         if (permission->value) {
74                 free((void *)permission->value);
75                 permission->value = NULL;
76         }
77         free((void*)permission);
78         permission = NULL;
79 }
80
81 static void __ps_free_icon(icon_x *icon)
82 {
83         if (icon == NULL)
84                 return;
85         if (icon->text) {
86                 free((void *)icon->text);
87                 icon->text = NULL;
88         }
89         if (icon->lang) {
90                 free((void *)icon->lang);
91                 icon->lang = NULL;
92         }
93         if (icon->name) {
94                 free((void *)icon->name);
95                 icon->name= NULL;
96         }
97         if (icon->section) {
98                 free((void *)icon->section);
99                 icon->section = NULL;
100         }
101         if (icon->size) {
102                 free((void *)icon->size);
103                 icon->size = NULL;
104         }
105         if (icon->resolution) {
106                 free((void *)icon->resolution);
107                 icon->resolution = NULL;
108         }
109         free((void*)icon);
110         icon = NULL;
111 }
112
113 static void __ps_free_image(image_x *image)
114 {
115         if (image == NULL)
116                 return;
117         if (image->text) {
118                 free((void *)image->text);
119                 image->text = NULL;
120         }
121         if (image->lang) {
122                 free((void *)image->lang);
123                 image->lang = NULL;
124         }
125         if (image->name) {
126                 free((void *)image->name);
127                 image->name= NULL;
128         }
129         if (image->section) {
130                 free((void *)image->section);
131                 image->section = NULL;
132         }
133         free((void*)image);
134         image = NULL;
135 }
136
137 static void __ps_free_operation(operation_x *operation)
138 {
139         if (operation == NULL)
140                 return;
141         if (operation->text) {
142                 free((void *)operation->text);
143                 operation->text = NULL;
144         }
145         free((void*)operation);
146         operation = NULL;
147 }
148
149 static void __ps_free_uri(uri_x *uri)
150 {
151         if (uri == NULL)
152                 return;
153         if (uri->text) {
154                 free((void *)uri->text);
155                 uri->text = NULL;
156         }
157         free((void*)uri);
158         uri = NULL;
159 }
160
161 static void __ps_free_mime(mime_x *mime)
162 {
163         if (mime == NULL)
164                 return;
165         if (mime->text) {
166                 free((void *)mime->text);
167                 mime->text = NULL;
168         }
169         free((void*)mime);
170         mime = NULL;
171 }
172
173 static void __ps_free_subapp(subapp_x *subapp)
174 {
175         if (subapp == NULL)
176                 return;
177         if (subapp->text) {
178                 free((void *)subapp->text);
179                 subapp->text = NULL;
180         }
181         free((void*)subapp);
182         subapp = NULL;
183 }
184
185 static void __ps_free_condition(condition_x *condition)
186 {
187         if (condition == NULL)
188                 return;
189         if (condition->text) {
190                 free((void *)condition->text);
191                 condition->text = NULL;
192         }
193         if (condition->name) {
194                 free((void *)condition->name);
195                 condition->name = NULL;
196         }
197         free((void*)condition);
198         condition = NULL;
199 }
200
201 static void __ps_free_notification(notification_x *notification)
202 {
203         if (notification == NULL)
204                 return;
205         if (notification->text) {
206                 free((void *)notification->text);
207                 notification->text = NULL;
208         }
209         if (notification->name) {
210                 free((void *)notification->name);
211                 notification->name = NULL;
212         }
213         free((void*)notification);
214         notification = NULL;
215 }
216
217 static void __ps_free_compatibility(compatibility_x *compatibility)
218 {
219         if (compatibility == NULL)
220                 return;
221         if (compatibility->text) {
222                 free((void *)compatibility->text);
223                 compatibility->text = NULL;
224         }
225         if (compatibility->name) {
226                 free((void *)compatibility->name);
227                 compatibility->name = NULL;
228         }
229         free((void*)compatibility);
230         compatibility = NULL;
231 }
232
233 static void __ps_free_allowed(allowed_x *allowed)
234 {
235         if (allowed == NULL)
236                 return;
237         if (allowed->name) {
238                 free((void *)allowed->name);
239                 allowed->name = NULL;
240         }
241         if (allowed->text) {
242                 free((void *)allowed->text);
243                 allowed->text = NULL;
244         }
245         free((void*)allowed);
246         allowed = NULL;
247 }
248
249 static void __ps_free_request(request_x *request)
250 {
251         if (request == NULL)
252                 return;
253         if (request->text) {
254                 free((void *)request->text);
255                 request->text = NULL;
256         }
257         free((void*)request);
258         request = NULL;
259 }
260
261 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
262 {
263         if (datacontrol == NULL)
264                 return;
265         if (datacontrol->providerid) {
266                 free((void *)datacontrol->providerid);
267                 datacontrol->providerid = NULL;
268         }
269         if (datacontrol->access) {
270                 free((void *)datacontrol->access);
271                 datacontrol->access = NULL;
272         }
273         if (datacontrol->type) {
274                 free((void *)datacontrol->type);
275                 datacontrol->type = NULL;
276         }
277         free((void*)datacontrol);
278         datacontrol = NULL;
279 }
280
281 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
282 {
283         if (launchconditions == NULL)
284                 return;
285         if (launchconditions->text) {
286                 free((void *)launchconditions->text);
287                 launchconditions->text = NULL;
288         }
289         /*Free Condition*/
290         if (launchconditions->condition) {
291                 condition_x *condition = launchconditions->condition;
292                 condition_x *tmp = NULL;
293                 while(condition != NULL) {
294                         tmp = condition->next;
295                         __ps_free_condition(condition);
296                         condition = tmp;
297                 }
298         }
299         free((void*)launchconditions);
300         launchconditions = NULL;
301 }
302
303 static void __ps_free_appcontrol(appcontrol_x *appcontrol)
304 {
305         if (appcontrol == NULL)
306                 return;
307         /*Free Operation*/
308         if (appcontrol->operation)
309                 free((void *)appcontrol->operation);
310         /*Free Uri*/
311         if (appcontrol->uri)
312                 free((void *)appcontrol->uri);
313         /*Free Mime*/
314         if (appcontrol->mime)
315                 free((void *)appcontrol->mime);
316         free((void*)appcontrol);
317         appcontrol = NULL;
318 }
319
320 static void __ps_free_appsvc(appsvc_x *appsvc)
321 {
322         if (appsvc == NULL)
323                 return;
324         if (appsvc->text) {
325                 free((void *)appsvc->text);
326                 appsvc->text = NULL;
327         }
328         /*Free Operation*/
329         if (appsvc->operation) {
330                 operation_x *operation = appsvc->operation;
331                 operation_x *tmp = NULL;
332                 while(operation != NULL) {
333                         tmp = operation->next;
334                         __ps_free_operation(operation);
335                         operation = tmp;
336                 }
337         }
338         /*Free Uri*/
339         if (appsvc->uri) {
340                 uri_x *uri = appsvc->uri;
341                 uri_x *tmp = NULL;
342                 while(uri != NULL) {
343                         tmp = uri->next;
344                         __ps_free_uri(uri);
345                         uri = tmp;
346                 }
347         }
348         /*Free Mime*/
349         if (appsvc->mime) {
350                 mime_x *mime = appsvc->mime;
351                 mime_x *tmp = NULL;
352                 while(mime != NULL) {
353                         tmp = mime->next;
354                         __ps_free_mime(mime);
355                         mime = tmp;
356                 }
357         }
358         /*Free subapp*/
359         if (appsvc->subapp) {
360                 subapp_x *subapp = appsvc->subapp;
361                 subapp_x *tmp = NULL;
362                 while(subapp != NULL) {
363                         tmp = subapp->next;
364                         __ps_free_subapp(subapp);
365                         subapp = tmp;
366                 }
367         }
368         free((void*)appsvc);
369         appsvc = NULL;
370 }
371
372 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
373 {
374         return;
375 }
376
377 static void __ps_free_define(define_x *define)
378 {
379         if (define == NULL)
380                 return;
381         if (define->path) {
382                 free((void *)define->path);
383                 define->path = NULL;
384         }
385         /*Free Request*/
386         if (define->request) {
387                 request_x *request = define->request;
388                 request_x *tmp = NULL;
389                 while(request != NULL) {
390                         tmp = request->next;
391                         __ps_free_request(request);
392                         request = tmp;
393                 }
394         }
395         /*Free Allowed*/
396         if (define->allowed) {
397                 allowed_x *allowed = define->allowed;
398                 allowed_x *tmp = NULL;
399                 while(allowed != NULL) {
400                         tmp = allowed->next;
401                         __ps_free_allowed(allowed);
402                         allowed = tmp;
403                 }
404         }
405         free((void*)define);
406         define = NULL;
407 }
408
409 static void __ps_free_datashare(datashare_x *datashare)
410 {
411         if (datashare == NULL)
412                 return;
413         /*Free Define*/
414         if (datashare->define) {
415                 define_x *define =  datashare->define;
416                 define_x *tmp = NULL;
417                 while(define != NULL) {
418                         tmp = define->next;
419                         __ps_free_define(define);
420                         define = tmp;
421                 }
422         }
423         /*Free Request*/
424         if (datashare->request) {
425                 request_x *request = datashare->request;
426                 request_x *tmp = NULL;
427                 while(request != NULL) {
428                         tmp = request->next;
429                         __ps_free_request(request);
430                         request = tmp;
431                 }
432         }
433         free((void*)datashare);
434         datashare = NULL;
435 }
436
437 static void __ps_free_label(label_x *label)
438 {
439         if (label == NULL)
440                 return;
441         if (label->name) {
442                 free((void *)label->name);
443                 label->name = NULL;
444         }
445         if (label->text) {
446                 free((void *)label->text);
447                 label->text = NULL;
448         }
449         if (label->lang) {
450                 free((void *)label->lang);
451                 label->lang= NULL;
452         }
453         free((void*)label);
454         label = NULL;
455 }
456
457 static void __ps_free_author(author_x *author)
458 {
459         if (author == NULL)
460                 return;
461         if (author->email) {
462                 free((void *)author->email);
463                 author->email = NULL;
464         }
465         if (author->text) {
466                 free((void *)author->text);
467                 author->text = NULL;
468         }
469         if (author->href) {
470                 free((void *)author->href);
471                 author->href = NULL;
472         }
473         if (author->lang) {
474                 free((void *)author->lang);
475                 author->lang = NULL;
476         }
477         free((void*)author);
478         author = NULL;
479 }
480
481 static void __ps_free_description(description_x *description)
482 {
483         if (description == NULL)
484                 return;
485         if (description->name) {
486                 free((void *)description->name);
487                 description->name = NULL;
488         }
489         if (description->text) {
490                 free((void *)description->text);
491                 description->text = NULL;
492         }
493         if (description->lang) {
494                 free((void *)description->lang);
495                 description->lang = NULL;
496         }
497         free((void*)description);
498         description = NULL;
499 }
500
501 static void __ps_free_license(license_x *license)
502 {
503         if (license == NULL)
504                 return;
505         if (license->text) {
506                 free((void *)license->text);
507                 license->text = NULL;
508         }
509         if (license->lang) {
510                 free((void *)license->lang);
511                 license->lang = NULL;
512         }
513         free((void*)license);
514         license = NULL;
515 }
516
517 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
518 {
519         if (uiapplication == NULL)
520                 return;
521         if (uiapplication->exec) {
522                 free((void *)uiapplication->exec);
523                 uiapplication->exec = NULL;
524         }
525         if (uiapplication->appid) {
526                 free((void *)uiapplication->appid);
527                 uiapplication->appid = NULL;
528         }
529         if (uiapplication->nodisplay) {
530                 free((void *)uiapplication->nodisplay);
531                 uiapplication->nodisplay = NULL;
532         }
533         if (uiapplication->multiple) {
534                 free((void *)uiapplication->multiple);
535                 uiapplication->multiple = NULL;
536         }
537         if (uiapplication->type) {
538                 free((void *)uiapplication->type);
539                 uiapplication->type = NULL;
540         }
541         if (uiapplication->categories) {
542                 free((void *)uiapplication->categories);
543                 uiapplication->categories = NULL;
544         }
545         if (uiapplication->extraid) {
546                 free((void *)uiapplication->extraid);
547                 uiapplication->extraid = NULL;
548         }
549         if (uiapplication->taskmanage) {
550                 free((void *)uiapplication->taskmanage);
551                 uiapplication->taskmanage = NULL;
552         }
553         if (uiapplication->enabled) {
554                 free((void *)uiapplication->enabled);
555                 uiapplication->enabled = NULL;
556         }
557         if (uiapplication->hwacceleration) {
558                 free((void *)uiapplication->hwacceleration);
559                 uiapplication->hwacceleration = NULL;
560         }
561         if (uiapplication->screenreader) {
562                 free((void *)uiapplication->screenreader);
563                 uiapplication->screenreader = NULL;
564         }
565         if (uiapplication->mainapp) {
566                 free((void *)uiapplication->mainapp);
567                 uiapplication->mainapp = NULL;
568         }
569         if (uiapplication->recentimage) {
570                 free((void *)uiapplication->recentimage);
571                 uiapplication->recentimage = NULL;
572         }
573         if (uiapplication->package) {
574                 free((void *)uiapplication->package);
575                 uiapplication->package = NULL;
576         }
577         if (uiapplication->launchcondition) {
578                 free((void *)uiapplication->launchcondition);
579                 uiapplication->launchcondition = NULL;
580         }
581         /*Free Label*/
582         if (uiapplication->label) {
583                 label_x *label = uiapplication->label;
584                 label_x *tmp = NULL;
585                 while(label != NULL) {
586                         tmp = label->next;
587                         __ps_free_label(label);
588                         label = tmp;
589                 }
590         }
591         /*Free Icon*/
592         if (uiapplication->icon) {
593                 icon_x *icon = uiapplication->icon;
594                 icon_x *tmp = NULL;
595                 while(icon != NULL) {
596                         tmp = icon->next;
597                         __ps_free_icon(icon);
598                         icon = tmp;
599                 }
600         }
601         /*Free image*/
602         if (uiapplication->image) {
603                 image_x *image = uiapplication->image;
604                 image_x *tmp = NULL;
605                 while(image != NULL) {
606                         tmp = image->next;
607                         __ps_free_image(image);
608                         image = tmp;
609                 }
610         }
611         /*Free AppControl*/
612         if (uiapplication->appcontrol) {
613                 appcontrol_x *appcontrol = uiapplication->appcontrol;
614                 appcontrol_x *tmp = NULL;
615                 while(appcontrol != NULL) {
616                         tmp = appcontrol->next;
617                         __ps_free_appcontrol(appcontrol);
618                         appcontrol = tmp;
619                 }
620         }
621         /*Free LaunchConditions*/
622         if (uiapplication->launchconditions) {
623                 launchconditions_x *launchconditions = uiapplication->launchconditions;
624                 launchconditions_x *tmp = NULL;
625                 while(launchconditions != NULL) {
626                         tmp = launchconditions->next;
627                         __ps_free_launchconditions(launchconditions);
628                         launchconditions = tmp;
629                 }
630         }
631         /*Free Notification*/
632         if (uiapplication->notification) {
633                 notification_x *notification = uiapplication->notification;
634                 notification_x *tmp = NULL;
635                 while(notification != NULL) {
636                         tmp = notification->next;
637                         __ps_free_notification(notification);
638                         notification = tmp;
639                 }
640         }
641         /*Free DataShare*/
642         if (uiapplication->datashare) {
643                 datashare_x *datashare = uiapplication->datashare;
644                 datashare_x *tmp = NULL;
645                 while(datashare != NULL) {
646                         tmp = datashare->next;
647                         __ps_free_datashare(datashare);
648                         datashare = tmp;
649                 }
650         }
651         /*Free AppSvc*/
652         if (uiapplication->appsvc) {
653                 appsvc_x *appsvc = uiapplication->appsvc;
654                 appsvc_x *tmp = NULL;
655                 while(appsvc != NULL) {
656                         tmp = appsvc->next;
657                         __ps_free_appsvc(appsvc);
658                         appsvc = tmp;
659                 }
660         }
661         /*Free Category*/
662         if (uiapplication->category) {
663                 category_x *category = uiapplication->category;
664                 category_x *tmp = NULL;
665                 while(category != NULL) {
666                         tmp = category->next;
667                         __ps_free_category(category);
668                         category = tmp;
669                 }
670         }
671         /*Free Metadata*/
672         if (uiapplication->metadata) {
673                 metadata_x *metadata = uiapplication->metadata;
674                 metadata_x *tmp = NULL;
675                 while(metadata != NULL) {
676                         tmp = metadata->next;
677                         __ps_free_metadata(metadata);
678                         metadata = tmp;
679                 }
680         }
681         /*Free permission*/
682         if (uiapplication->permission) {
683                 permission_x *permission = uiapplication->permission;
684                 permission_x *tmp = NULL;
685                 while(permission != NULL) {
686                         tmp = permission->next;
687                         __ps_free_permission(permission);
688                         permission = tmp;
689                 }
690         }
691         /*Free DataControl*/
692         if (uiapplication->datacontrol) {
693                 datacontrol_x *datacontrol = uiapplication->datacontrol;
694                 datacontrol_x *tmp = NULL;
695                 while(datacontrol != NULL) {
696                         tmp = datacontrol->next;
697                         __ps_free_datacontrol(datacontrol);
698                         datacontrol = tmp;
699                 }
700         }
701         /* _PRODUCT_LAUNCHING_ENHANCED_ START */
702         if (uiapplication->indicatordisplay) {
703                 free((void *)uiapplication->indicatordisplay);
704                 uiapplication->indicatordisplay = NULL;
705         }
706         if (uiapplication->portraitimg) {
707                 free((void *)uiapplication->portraitimg);
708                 uiapplication->portraitimg = NULL;
709         }
710         if (uiapplication->landscapeimg) {
711                 free((void *)uiapplication->landscapeimg);
712                 uiapplication->landscapeimg = NULL;
713         }
714         /* _PRODUCT_LAUNCHING_ENHANCED_ END */
715         if (uiapplication->guestmode_visibility) {
716                 free((void *)uiapplication->guestmode_visibility);
717                 uiapplication->guestmode_visibility = NULL;
718         }
719         if (uiapplication->app_component) {
720                 free((void *)uiapplication->app_component);
721                 uiapplication->app_component = NULL;
722         }
723         if (uiapplication->permission_type) {
724                 free((void *)uiapplication->permission_type);
725                 uiapplication->permission_type = NULL;
726         }
727         if (uiapplication->component_type) {
728                 free((void *)uiapplication->component_type);
729                 uiapplication->component_type = NULL;
730         }
731         if (uiapplication->preload) {
732                 free((void *)uiapplication->preload);
733                 uiapplication->preload = NULL;
734         }
735         if (uiapplication->submode) {
736                 free((void *)uiapplication->submode);
737                 uiapplication->submode = NULL;
738         }
739         if (uiapplication->submode_mainid) {
740                 free((void *)uiapplication->submode_mainid);
741                 uiapplication->submode_mainid = NULL;
742         }
743
744         free((void*)uiapplication);
745         uiapplication = NULL;
746 }
747
748 static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
749 {
750         if (serviceapplication == NULL)
751                 return;
752         if (serviceapplication->exec) {
753                 free((void *)serviceapplication->exec);
754                 serviceapplication->exec = NULL;
755         }
756         if (serviceapplication->appid) {
757                 free((void *)serviceapplication->appid);
758                 serviceapplication->appid = NULL;
759         }
760         if (serviceapplication->onboot) {
761                 free((void *)serviceapplication->onboot);
762                 serviceapplication->onboot = NULL;
763         }
764         if (serviceapplication->autorestart) {
765                 free((void *)serviceapplication->autorestart);
766                 serviceapplication->autorestart = NULL;
767         }
768         if (serviceapplication->type) {
769                 free((void *)serviceapplication->type);
770                 serviceapplication->type = NULL;
771         }
772         if (serviceapplication->enabled) {
773                 free((void *)serviceapplication->enabled);
774                 serviceapplication->enabled = NULL;
775         }
776         if (serviceapplication->package) {
777                 free((void *)serviceapplication->package);
778                 serviceapplication->package = NULL;
779         }
780         if (serviceapplication->permission_type) {
781                 free((void *)serviceapplication->permission_type);
782                 serviceapplication->permission_type = NULL;
783         }
784         /*Free Label*/
785         if (serviceapplication->label) {
786                 label_x *label = serviceapplication->label;
787                 label_x *tmp = NULL;
788                 while(label != NULL) {
789                         tmp = label->next;
790                         __ps_free_label(label);
791                         label = tmp;
792                 }
793         }
794         /*Free Icon*/
795         if (serviceapplication->icon) {
796                 icon_x *icon = serviceapplication->icon;
797                 icon_x *tmp = NULL;
798                 while(icon != NULL) {
799                         tmp = icon->next;
800                         __ps_free_icon(icon);
801                         icon = tmp;
802                 }
803         }
804         /*Free AppControl*/
805         if (serviceapplication->appcontrol) {
806                 appcontrol_x *appcontrol = serviceapplication->appcontrol;
807                 appcontrol_x *tmp = NULL;
808                 while(appcontrol != NULL) {
809                         tmp = appcontrol->next;
810                         __ps_free_appcontrol(appcontrol);
811                         appcontrol = tmp;
812                 }
813         }
814         /*Free DataControl*/
815         if (serviceapplication->datacontrol) {
816                 datacontrol_x *datacontrol = serviceapplication->datacontrol;
817                 datacontrol_x *tmp = NULL;
818                 while(datacontrol != NULL) {
819                         tmp = datacontrol->next;
820                         __ps_free_datacontrol(datacontrol);
821                         datacontrol = tmp;
822                 }
823         }
824         /*Free LaunchConditions*/
825         if (serviceapplication->launchconditions) {
826                 launchconditions_x *launchconditions = serviceapplication->launchconditions;
827                 launchconditions_x *tmp = NULL;
828                 while(launchconditions != NULL) {
829                         tmp = launchconditions->next;
830                         __ps_free_launchconditions(launchconditions);
831                         launchconditions = tmp;
832                 }
833         }
834         /*Free Notification*/
835         if (serviceapplication->notification) {
836                 notification_x *notification = serviceapplication->notification;
837                 notification_x *tmp = NULL;
838                 while(notification != NULL) {
839                         tmp = notification->next;
840                         __ps_free_notification(notification);
841                         notification = tmp;
842                 }
843         }
844         /*Free DataShare*/
845         if (serviceapplication->datashare) {
846                 datashare_x *datashare = serviceapplication->datashare;
847                 datashare_x *tmp = NULL;
848                 while(datashare != NULL) {
849                         tmp = datashare->next;
850                         __ps_free_datashare(datashare);
851                         datashare = tmp;
852                 }
853         }
854         /*Free AppSvc*/
855         if (serviceapplication->appsvc) {
856                 appsvc_x *appsvc = serviceapplication->appsvc;
857                 appsvc_x *tmp = NULL;
858                 while(appsvc != NULL) {
859                         tmp = appsvc->next;
860                         __ps_free_appsvc(appsvc);
861                         appsvc = tmp;
862                 }
863         }
864         /*Free Category*/
865         if (serviceapplication->category) {
866                 category_x *category = serviceapplication->category;
867                 category_x *tmp = NULL;
868                 while(category != NULL) {
869                         tmp = category->next;
870                         __ps_free_category(category);
871                         category = tmp;
872                 }
873         }
874         /*Free Metadata*/
875         if (serviceapplication->metadata) {
876                 metadata_x *metadata = serviceapplication->metadata;
877                 metadata_x *tmp = NULL;
878                 while(metadata != NULL) {
879                         tmp = metadata->next;
880                         __ps_free_metadata(metadata);
881                         metadata = tmp;
882                 }
883         }
884         /*Free permission*/
885         if (serviceapplication->permission) {
886                 permission_x *permission = serviceapplication->permission;
887                 permission_x *tmp = NULL;
888                 while(permission != NULL) {
889                         tmp = permission->next;
890                         __ps_free_permission(permission);
891                         permission = tmp;
892                 }
893         }
894         free((void*)serviceapplication);
895         serviceapplication = NULL;
896 }
897
898 static void __ps_free_font(font_x *font)
899 {
900         if (font == NULL)
901                 return;
902         if (font->name) {
903                 free((void *)font->name);
904                 font->name = NULL;
905         }
906         if (font->text) {
907                 free((void *)font->text);
908                 font->text = NULL;
909         }
910         free((void*)font);
911         font = NULL;
912 }
913
914 static void __ps_free_theme(theme_x *theme)
915 {
916         if (theme == NULL)
917                 return;
918         if (theme->name) {
919                 free((void *)theme->name);
920                 theme->name = NULL;
921         }
922         if (theme->text) {
923                 free((void *)theme->text);
924                 theme->text = NULL;
925         }
926         free((void*)theme);
927         theme = NULL;
928 }
929
930 static void __ps_free_daemon(daemon_x *daemon)
931 {
932         if (daemon == NULL)
933                 return;
934         if (daemon->name) {
935                 free((void *)daemon->name);
936                 daemon->name = NULL;
937         }
938         if (daemon->text) {
939                 free((void *)daemon->text);
940                 daemon->text = NULL;
941         }
942         free((void*)daemon);
943         daemon = NULL;
944 }
945
946 static void __ps_free_ime(ime_x *ime)
947 {
948         if (ime == NULL)
949                 return;
950         if (ime->name) {
951                 free((void *)ime->name);
952                 ime->name = NULL;
953         }
954         if (ime->text) {
955                 free((void *)ime->text);
956                 ime->text = NULL;
957         }
958         free((void*)ime);
959         ime = NULL;
960 }
961
962 API void pkgmgrinfo_basic_free_application(application_x *application)
963 {
964         if (application == NULL)
965                 return;
966
967         if (application->appid)
968                 free((void *)application->appid);
969         if (application->component)
970                 free((void *)application->component);
971         if (application->exec)
972                 free((void *)application->exec);
973         if (application->nodisplay)
974                 free((void *)application->nodisplay);
975         if (application->type)
976                 free((void *)application->type);
977         if (application->onboot)
978                 free((void *)application->onboot);
979         if (application->multiple)
980                 free((void *)application->multiple);
981         if (application->autorestart)
982                 free((void *)application->autorestart);
983         if (application->taskmanage)
984                 free((void *)application->taskmanage);
985         if (application->enabled)
986                 free((void *)application->enabled);
987         if (application->hwacceleration)
988                 free((void *)application->hwacceleration);
989         if (application->screenreader)
990                 free((void *)application->screenreader);
991         if (application->mainapp)
992                 free((void *)application->mainapp);
993         if (application->recentimage)
994                 free((void *)application->recentimage);
995         if (application->launchcondition)
996                 free((void *)application->launchcondition);
997         if (application->indicatordisplay)
998                 free((void *)application->indicatordisplay);
999         if (application->portraitimg)
1000                 free((void *)application->portraitimg);
1001         if (application->landscapeimg)
1002                 free((void *)application->landscapeimg);
1003         if (application->guestmode_visibility)
1004                 free((void *)application->guestmode_visibility);
1005         if (application->permission_type)
1006                 free((void *)application->permission_type);
1007         if (application->preload)
1008                 free((void *)application->preload);
1009         if (application->submode)
1010                 free((void *)application->submode);
1011         if (application->submode_mainid)
1012                 free((void *)application->submode_mainid);
1013         if (application->launch_mode)
1014                 free((void *)application->launch_mode);
1015         if (application->component_type)
1016                 free((void *)application->component_type);
1017         if (application->package)
1018                 free((void *)application->package);
1019
1020         /*Free Label*/
1021         if (application->label) {
1022                 label_x *label = application->label;
1023                 label_x *tmp = NULL;
1024                 while(label != NULL) {
1025                         tmp = label->next;
1026                         __ps_free_label(label);
1027                         label = tmp;
1028                 }
1029         }
1030         /*Free Icon*/
1031         if (application->icon) {
1032                 icon_x *icon = application->icon;
1033                 icon_x *tmp = NULL;
1034                 while(icon != NULL) {
1035                         tmp = icon->next;
1036                         __ps_free_icon(icon);
1037                         icon = tmp;
1038                 }
1039         }
1040         /*Free image*/
1041         if (application->image) {
1042                 image_x *image = application->image;
1043                 image_x *tmp = NULL;
1044                 while(image != NULL) {
1045                         tmp = image->next;
1046                         __ps_free_image(image);
1047                         image = tmp;
1048                 }
1049         }
1050         /*Free AppSvc*/
1051         if (application->appsvc) {
1052                 appsvc_x *appsvc = application->appsvc;
1053                 appsvc_x *tmp = NULL;
1054                 while(appsvc != NULL) {
1055                         tmp = appsvc->next;
1056                         __ps_free_appsvc(appsvc);
1057                         appsvc = tmp;
1058                 }
1059         }
1060         /*Free AppControl*/
1061         if (application->appcontrol) {
1062                 appcontrol_x *appcontrol = application->appcontrol;
1063                 appcontrol_x *tmp = NULL;
1064                 while(appcontrol != NULL) {
1065                         tmp = appcontrol->next;
1066                         __ps_free_appcontrol(appcontrol);
1067                         appcontrol = tmp;
1068                 }
1069         }
1070         /*Free Category*/
1071         if (application->category) {
1072                 category_x *category = application->category;
1073                 category_x *tmp = NULL;
1074                 while(category != NULL) {
1075                         tmp = category->next;
1076                         __ps_free_category(category);
1077                         category = tmp;
1078                 }
1079         }
1080         /*Free Metadata*/
1081         if (application->metadata) {
1082                 metadata_x *metadata = application->metadata;
1083                 metadata_x *tmp = NULL;
1084                 while(metadata != NULL) {
1085                         tmp = metadata->next;
1086                         __ps_free_metadata(metadata);
1087                         metadata = tmp;
1088                 }
1089         }
1090         /*Free permission*/
1091         if (application->permission) {
1092                 permission_x *permission = application->permission;
1093                 permission_x *tmp = NULL;
1094                 while(permission != NULL) {
1095                         tmp = permission->next;
1096                         __ps_free_permission(permission);
1097                         permission = tmp;
1098                 }
1099         }
1100         /*Free LaunchConditions*/
1101         if (application->launchconditions) {
1102                 launchconditions_x *launchconditions = application->launchconditions;
1103                 launchconditions_x *tmp = NULL;
1104                 while(launchconditions != NULL) {
1105                         tmp = launchconditions->next;
1106                         __ps_free_launchconditions(launchconditions);
1107                         launchconditions = tmp;
1108                 }
1109         }
1110         /*Free Notification*/
1111         if (application->notification) {
1112                 notification_x *notification = application->notification;
1113                 notification_x *tmp = NULL;
1114                 while(notification != NULL) {
1115                         tmp = notification->next;
1116                         __ps_free_notification(notification);
1117                         notification = tmp;
1118                 }
1119         }
1120         /*Free DataShare*/
1121         if (application->datashare) {
1122                 datashare_x *datashare = application->datashare;
1123                 datashare_x *tmp = NULL;
1124                 while(datashare != NULL) {
1125                         tmp = datashare->next;
1126                         __ps_free_datashare(datashare);
1127                         datashare = tmp;
1128                 }
1129         }
1130         /*Free DataControl*/
1131         if (application->datacontrol) {
1132                 datacontrol_x *datacontrol = application->datacontrol;
1133                 datacontrol_x *tmp = NULL;
1134                 while(datacontrol != NULL) {
1135                         tmp = datacontrol->next;
1136                         __ps_free_datacontrol(datacontrol);
1137                         datacontrol = tmp;
1138                 }
1139         }
1140         free((void *)application);
1141 }
1142
1143 API void pkgmgrinfo_basic_free_package(package_x *package)
1144 {
1145         if (package == NULL)
1146                 return;
1147         if (package->for_all_users) {
1148                 free((void *)package->for_all_users);
1149                 package->for_all_users = NULL;
1150         }
1151         if (package->ns) {
1152                 free((void *)package->ns);
1153                 package->ns = NULL;
1154         }
1155         if (package->package) {
1156                 free((void *)package->package);
1157                 package->package = NULL;
1158         }
1159         if (package->version) {
1160                 free((void *)package->version);
1161                 package->version = NULL;
1162         }
1163         if (package->installlocation) {
1164                 free((void *)package->installlocation);
1165                 package->installlocation = NULL;
1166         }
1167         if (package->preload) {
1168                 free((void *)package->preload);
1169                 package->preload = NULL;
1170         }
1171         if (package->readonly) {
1172                 free((void *)package->readonly);
1173                 package->readonly = NULL;
1174         }
1175         if (package->removable) {
1176                 free((void *)package->removable);
1177                 package->removable = NULL;
1178         }
1179         if (package->update) {
1180                 free((void *)package->update);
1181                 package->update = NULL;
1182         }
1183         if (package->system) {
1184                 free((void *)package->system);
1185                 package->system = NULL;
1186         }
1187         if (package->type) {
1188                 free((void *)package->type);
1189                 package->type = NULL;
1190         }
1191         if (package->package_size) {
1192                 free((void *)package->package_size);
1193                 package->package_size = NULL;
1194         }
1195         if (package->installed_time) {
1196                 free((void *)package->installed_time);
1197                 package->installed_time = NULL;
1198         }
1199         if (package->installed_storage) {
1200                 free((void *)package->installed_storage);
1201                 package->installed_storage = NULL;
1202         }
1203         if (package->storeclient_id) {
1204                 free((void *)package->storeclient_id);
1205                 package->storeclient_id = NULL;
1206         }
1207         if (package->mainapp_id) {
1208                 free((void *)package->mainapp_id);
1209                 package->mainapp_id = NULL;
1210         }
1211         if (package->package_url) {
1212                 free((void *)package->package_url);
1213                 package->package_url = NULL;
1214         }
1215         if (package->root_path) {
1216                 free((void *)package->root_path);
1217                 package->root_path = NULL;
1218         }
1219         if (package->csc_path) {
1220                 free((void *)package->csc_path);
1221                 package->csc_path = NULL;
1222         }
1223         if (package->appsetting) {
1224                 free((void *)package->appsetting);
1225                 package->appsetting = NULL;
1226         }
1227         if (package->nodisplay_setting) {
1228                 free((void *)package->nodisplay_setting);
1229                 package->nodisplay_setting = NULL;
1230         }
1231         if (package->api_version) {
1232                 free((void *)package->api_version);
1233                 package->api_version = NULL;
1234         }
1235
1236         /*Free Icon*/
1237         if (package->icon) {
1238                 icon_x *icon = package->icon;
1239                 icon_x *tmp = NULL;
1240                 while(icon != NULL) {
1241                         tmp = icon->next;
1242                         __ps_free_icon(icon);
1243                         icon = tmp;
1244                 }
1245         }
1246         /*Free Label*/
1247         if (package->label) {
1248                 label_x *label = package->label;
1249                 label_x *tmp = NULL;
1250                 while(label != NULL) {
1251                         tmp = label->next;
1252                         __ps_free_label(label);
1253                         label = tmp;
1254                 }
1255         }
1256         /*Free Author*/
1257         if (package->author) {
1258                 author_x *author = package->author;
1259                 author_x *tmp = NULL;
1260                 while(author != NULL) {
1261                         tmp = author->next;
1262                         __ps_free_author(author);
1263                         author = tmp;
1264                 }
1265         }
1266         /*Free Description*/
1267         if (package->description) {
1268                 description_x *description = package->description;
1269                 description_x *tmp = NULL;
1270                 while(description != NULL) {
1271                         tmp = description->next;
1272                         __ps_free_description(description);
1273                         description = tmp;
1274                 }
1275         }
1276         /*Free License*/
1277         if (package->license) {
1278                 license_x *license = package->license;
1279                 license_x *tmp = NULL;
1280                 while(license != NULL) {
1281                         tmp = license->next;
1282                         __ps_free_license(license);
1283                         license = tmp;
1284                 }
1285         }
1286         /*Free Privileges*/
1287         if (package->privileges) {
1288                 privileges_x *privileges = package->privileges;
1289                 privileges_x *tmp = NULL;
1290                 while(privileges != NULL) {
1291                         tmp = privileges->next;
1292                         __ps_free_privileges(privileges);
1293                         privileges = tmp;
1294                 }
1295         }
1296         /*Free UiApplication*/
1297         if (package->uiapplication) {
1298                 uiapplication_x *uiapplication = package->uiapplication;
1299                 uiapplication_x *tmp = NULL;
1300                 while(uiapplication != NULL) {
1301                         tmp = uiapplication->next;
1302                         __ps_free_uiapplication(uiapplication);
1303                         uiapplication = tmp;
1304                 }
1305         }
1306         /*Free ServiceApplication*/
1307         if (package->serviceapplication) {
1308                 serviceapplication_x *serviceapplication = package->serviceapplication;
1309                 serviceapplication_x *tmp = NULL;
1310                 while(serviceapplication != NULL) {
1311                         tmp = serviceapplication->next;
1312                         __ps_free_serviceapplication(serviceapplication);
1313                         serviceapplication = tmp;
1314                 }
1315         }
1316         /*Free Daemon*/
1317         if (package->daemon) {
1318                 daemon_x *daemon = package->daemon;
1319                 daemon_x *tmp = NULL;
1320                 while(daemon != NULL) {
1321                         tmp = daemon->next;
1322                         __ps_free_daemon(daemon);
1323                         daemon = tmp;
1324                 }
1325         }
1326         /*Free Theme*/
1327         if (package->theme) {
1328                 theme_x *theme = package->theme;
1329                 theme_x *tmp = NULL;
1330                 while(theme != NULL) {
1331                         tmp = theme->next;
1332                         __ps_free_theme(theme);
1333                         theme = tmp;
1334                 }
1335         }
1336         /*Free Font*/
1337         if (package->font) {
1338                 font_x *font = package->font;
1339                 font_x *tmp = NULL;
1340                 while(font != NULL) {
1341                         tmp = font->next;
1342                         __ps_free_font(font);
1343                         font = tmp;
1344                 }
1345         }
1346         /*Free Ime*/
1347         if (package->ime) {
1348                 ime_x *ime = package->ime;
1349                 ime_x *tmp = NULL;
1350                 while(ime != NULL) {
1351                         tmp = ime->next;
1352                         __ps_free_ime(ime);
1353                         ime = tmp;
1354                 }
1355         }
1356         /*Free Compatibility*/
1357         if (package->compatibility) {
1358                 compatibility_x *compatibility = package->compatibility;
1359                 compatibility_x *tmp = NULL;
1360                 while(compatibility != NULL) {
1361                         tmp = compatibility->next;
1362                         __ps_free_compatibility(compatibility);
1363                         compatibility = tmp;
1364                 }
1365         }
1366         /*Free DeviceProfile*/
1367         if (package->deviceprofile) {
1368                 deviceprofile_x *deviceprofile = package->deviceprofile;
1369                 deviceprofile_x *tmp = NULL;
1370                 while(deviceprofile != NULL) {
1371                         tmp = deviceprofile->next;
1372                         __ps_free_deviceprofile(deviceprofile);
1373                         deviceprofile = tmp;
1374                 }
1375         }
1376         free((void*)package);
1377         package = NULL;
1378         return;
1379 }
1380