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