Unify uiapplication_x and serviceapplication_x
[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_font(font_x *font)
517 {
518         if (font == NULL)
519                 return;
520         if (font->name) {
521                 free((void *)font->name);
522                 font->name = NULL;
523         }
524         if (font->text) {
525                 free((void *)font->text);
526                 font->text = NULL;
527         }
528         free((void*)font);
529         font = NULL;
530 }
531
532 static void __ps_free_theme(theme_x *theme)
533 {
534         if (theme == NULL)
535                 return;
536         if (theme->name) {
537                 free((void *)theme->name);
538                 theme->name = NULL;
539         }
540         if (theme->text) {
541                 free((void *)theme->text);
542                 theme->text = NULL;
543         }
544         free((void*)theme);
545         theme = NULL;
546 }
547
548 static void __ps_free_daemon(daemon_x *daemon)
549 {
550         if (daemon == NULL)
551                 return;
552         if (daemon->name) {
553                 free((void *)daemon->name);
554                 daemon->name = NULL;
555         }
556         if (daemon->text) {
557                 free((void *)daemon->text);
558                 daemon->text = NULL;
559         }
560         free((void*)daemon);
561         daemon = NULL;
562 }
563
564 static void __ps_free_ime(ime_x *ime)
565 {
566         if (ime == NULL)
567                 return;
568         if (ime->name) {
569                 free((void *)ime->name);
570                 ime->name = NULL;
571         }
572         if (ime->text) {
573                 free((void *)ime->text);
574                 ime->text = NULL;
575         }
576         free((void*)ime);
577         ime = NULL;
578 }
579
580 static void __ps_free_application(application_x *application)
581 {
582         if (application == NULL)
583                 return;
584
585         if (application->appid)
586                 free((void *)application->appid);
587         if (application->component)
588                 free((void *)application->component);
589         if (application->exec)
590                 free((void *)application->exec);
591         if (application->nodisplay)
592                 free((void *)application->nodisplay);
593         if (application->type)
594                 free((void *)application->type);
595         if (application->onboot)
596                 free((void *)application->onboot);
597         if (application->multiple)
598                 free((void *)application->multiple);
599         if (application->autorestart)
600                 free((void *)application->autorestart);
601         if (application->taskmanage)
602                 free((void *)application->taskmanage);
603         if (application->enabled)
604                 free((void *)application->enabled);
605         if (application->categories)
606                 free((void *)application->categories);
607         if (application->extraid)
608                 free((void *)application->extraid);
609         if (application->hwacceleration)
610                 free((void *)application->hwacceleration);
611         if (application->screenreader)
612                 free((void *)application->screenreader);
613         if (application->mainapp)
614                 free((void *)application->mainapp);
615         if (application->recentimage)
616                 free((void *)application->recentimage);
617         if (application->launchcondition)
618                 free((void *)application->launchcondition);
619         if (application->indicatordisplay)
620                 free((void *)application->indicatordisplay);
621         if (application->portraitimg)
622                 free((void *)application->portraitimg);
623         if (application->landscapeimg)
624                 free((void *)application->landscapeimg);
625         if (application->guestmode_visibility)
626                 free((void *)application->guestmode_visibility);
627         if (application->permission_type)
628                 free((void *)application->permission_type);
629         if (application->preload)
630                 free((void *)application->preload);
631         if (application->submode)
632                 free((void *)application->submode);
633         if (application->submode_mainid)
634                 free((void *)application->submode_mainid);
635         if (application->launch_mode)
636                 free((void *)application->launch_mode);
637         if (application->ui_gadget)
638                 free((void *)application->ui_gadget);
639         if (application->component_type)
640                 free((void *)application->component_type);
641         if (application->package)
642                 free((void *)application->package);
643         if (application->support_disable)
644                 free((void *)application->support_disable);
645
646         /*Free Label*/
647         if (application->label) {
648                 label_x *label = application->label;
649                 label_x *tmp = NULL;
650                 while(label != NULL) {
651                         tmp = label->next;
652                         __ps_free_label(label);
653                         label = tmp;
654                 }
655         }
656         /*Free Icon*/
657         if (application->icon) {
658                 icon_x *icon = application->icon;
659                 icon_x *tmp = NULL;
660                 while(icon != NULL) {
661                         tmp = icon->next;
662                         __ps_free_icon(icon);
663                         icon = tmp;
664                 }
665         }
666         /*Free image*/
667         if (application->image) {
668                 image_x *image = application->image;
669                 image_x *tmp = NULL;
670                 while(image != NULL) {
671                         tmp = image->next;
672                         __ps_free_image(image);
673                         image = tmp;
674                 }
675         }
676         /*Free AppSvc*/
677         if (application->appsvc) {
678                 appsvc_x *appsvc = application->appsvc;
679                 appsvc_x *tmp = NULL;
680                 while(appsvc != NULL) {
681                         tmp = appsvc->next;
682                         __ps_free_appsvc(appsvc);
683                         appsvc = tmp;
684                 }
685         }
686         /*Free AppControl*/
687         if (application->appcontrol) {
688                 appcontrol_x *appcontrol = application->appcontrol;
689                 appcontrol_x *tmp = NULL;
690                 while(appcontrol != NULL) {
691                         tmp = appcontrol->next;
692                         __ps_free_appcontrol(appcontrol);
693                         appcontrol = tmp;
694                 }
695         }
696         /*Free Category*/
697         if (application->category) {
698                 category_x *category = application->category;
699                 category_x *tmp = NULL;
700                 while(category != NULL) {
701                         tmp = category->next;
702                         __ps_free_category(category);
703                         category = tmp;
704                 }
705         }
706         /*Free Metadata*/
707         if (application->metadata) {
708                 metadata_x *metadata = application->metadata;
709                 metadata_x *tmp = NULL;
710                 while(metadata != NULL) {
711                         tmp = metadata->next;
712                         __ps_free_metadata(metadata);
713                         metadata = tmp;
714                 }
715         }
716         /*Free permission*/
717         if (application->permission) {
718                 permission_x *permission = application->permission;
719                 permission_x *tmp = NULL;
720                 while(permission != NULL) {
721                         tmp = permission->next;
722                         __ps_free_permission(permission);
723                         permission = tmp;
724                 }
725         }
726         /*Free LaunchConditions*/
727         if (application->launchconditions) {
728                 launchconditions_x *launchconditions = application->launchconditions;
729                 launchconditions_x *tmp = NULL;
730                 while(launchconditions != NULL) {
731                         tmp = launchconditions->next;
732                         __ps_free_launchconditions(launchconditions);
733                         launchconditions = tmp;
734                 }
735         }
736         /*Free Notification*/
737         if (application->notification) {
738                 notification_x *notification = application->notification;
739                 notification_x *tmp = NULL;
740                 while(notification != NULL) {
741                         tmp = notification->next;
742                         __ps_free_notification(notification);
743                         notification = tmp;
744                 }
745         }
746         /*Free DataShare*/
747         if (application->datashare) {
748                 datashare_x *datashare = application->datashare;
749                 datashare_x *tmp = NULL;
750                 while(datashare != NULL) {
751                         tmp = datashare->next;
752                         __ps_free_datashare(datashare);
753                         datashare = tmp;
754                 }
755         }
756         /*Free DataControl*/
757         if (application->datacontrol) {
758                 datacontrol_x *datacontrol = application->datacontrol;
759                 datacontrol_x *tmp = NULL;
760                 while(datacontrol != NULL) {
761                         tmp = datacontrol->next;
762                         __ps_free_datacontrol(datacontrol);
763                         datacontrol = tmp;
764                 }
765         }
766         free((void *)application);
767 }
768
769 API void pkgmgrinfo_basic_free_application(application_x *application)
770 {
771         __ps_free_application(application);
772 }
773
774 API void pkgmgrinfo_basic_free_package(package_x *package)
775 {
776         if (package == NULL)
777                 return;
778         if (package->for_all_users) {
779                 free((void *)package->for_all_users);
780                 package->for_all_users = NULL;
781         }
782         if (package->ns) {
783                 free((void *)package->ns);
784                 package->ns = NULL;
785         }
786         if (package->package) {
787                 free((void *)package->package);
788                 package->package = NULL;
789         }
790         if (package->version) {
791                 free((void *)package->version);
792                 package->version = NULL;
793         }
794         if (package->installlocation) {
795                 free((void *)package->installlocation);
796                 package->installlocation = NULL;
797         }
798         if (package->preload) {
799                 free((void *)package->preload);
800                 package->preload = NULL;
801         }
802         if (package->readonly) {
803                 free((void *)package->readonly);
804                 package->readonly = NULL;
805         }
806         if (package->removable) {
807                 free((void *)package->removable);
808                 package->removable = NULL;
809         }
810         if (package->update) {
811                 free((void *)package->update);
812                 package->update = NULL;
813         }
814         if (package->system) {
815                 free((void *)package->system);
816                 package->system = NULL;
817         }
818         if (package->type) {
819                 free((void *)package->type);
820                 package->type = NULL;
821         }
822         if (package->package_size) {
823                 free((void *)package->package_size);
824                 package->package_size = NULL;
825         }
826         if (package->installed_time) {
827                 free((void *)package->installed_time);
828                 package->installed_time = NULL;
829         }
830         if (package->installed_storage) {
831                 free((void *)package->installed_storage);
832                 package->installed_storage = NULL;
833         }
834         if (package->storeclient_id) {
835                 free((void *)package->storeclient_id);
836                 package->storeclient_id = NULL;
837         }
838         if (package->mainapp_id) {
839                 free((void *)package->mainapp_id);
840                 package->mainapp_id = NULL;
841         }
842         if (package->package_url) {
843                 free((void *)package->package_url);
844                 package->package_url = NULL;
845         }
846         if (package->root_path) {
847                 free((void *)package->root_path);
848                 package->root_path = NULL;
849         }
850         if (package->csc_path) {
851                 free((void *)package->csc_path);
852                 package->csc_path = NULL;
853         }
854         if (package->appsetting) {
855                 free((void *)package->appsetting);
856                 package->appsetting = NULL;
857         }
858         if (package->nodisplay_setting) {
859                 free((void *)package->nodisplay_setting);
860                 package->nodisplay_setting = NULL;
861         }
862         if (package->api_version) {
863                 free((void *)package->api_version);
864                 package->api_version = NULL;
865         }
866         if (package->support_disable) {
867                 free((void *)package->support_disable);
868                 package->support_disable = NULL;
869         }
870
871         /*Free Icon*/
872         if (package->icon) {
873                 icon_x *icon = package->icon;
874                 icon_x *tmp = NULL;
875                 while(icon != NULL) {
876                         tmp = icon->next;
877                         __ps_free_icon(icon);
878                         icon = tmp;
879                 }
880         }
881         /*Free Label*/
882         if (package->label) {
883                 label_x *label = package->label;
884                 label_x *tmp = NULL;
885                 while(label != NULL) {
886                         tmp = label->next;
887                         __ps_free_label(label);
888                         label = tmp;
889                 }
890         }
891         /*Free Author*/
892         if (package->author) {
893                 author_x *author = package->author;
894                 author_x *tmp = NULL;
895                 while(author != NULL) {
896                         tmp = author->next;
897                         __ps_free_author(author);
898                         author = tmp;
899                 }
900         }
901         /*Free Description*/
902         if (package->description) {
903                 description_x *description = package->description;
904                 description_x *tmp = NULL;
905                 while(description != NULL) {
906                         tmp = description->next;
907                         __ps_free_description(description);
908                         description = tmp;
909                 }
910         }
911         /*Free License*/
912         if (package->license) {
913                 license_x *license = package->license;
914                 license_x *tmp = NULL;
915                 while(license != NULL) {
916                         tmp = license->next;
917                         __ps_free_license(license);
918                         license = tmp;
919                 }
920         }
921         /*Free Privileges*/
922         if (package->privileges) {
923                 privileges_x *privileges = package->privileges;
924                 privileges_x *tmp = NULL;
925                 while(privileges != NULL) {
926                         tmp = privileges->next;
927                         __ps_free_privileges(privileges);
928                         privileges = tmp;
929                 }
930         }
931         /*Free Application*/
932         if (package->application) {
933                 application_x *application = package->application;
934                 application_x *tmp = NULL;
935                 while(application != NULL) {
936                         tmp = application->next;
937                         __ps_free_application(application);
938                         application = tmp;
939                 }
940         }
941         /*Free Daemon*/
942         if (package->daemon) {
943                 daemon_x *daemon = package->daemon;
944                 daemon_x *tmp = NULL;
945                 while(daemon != NULL) {
946                         tmp = daemon->next;
947                         __ps_free_daemon(daemon);
948                         daemon = tmp;
949                 }
950         }
951         /*Free Theme*/
952         if (package->theme) {
953                 theme_x *theme = package->theme;
954                 theme_x *tmp = NULL;
955                 while(theme != NULL) {
956                         tmp = theme->next;
957                         __ps_free_theme(theme);
958                         theme = tmp;
959                 }
960         }
961         /*Free Font*/
962         if (package->font) {
963                 font_x *font = package->font;
964                 font_x *tmp = NULL;
965                 while(font != NULL) {
966                         tmp = font->next;
967                         __ps_free_font(font);
968                         font = tmp;
969                 }
970         }
971         /*Free Ime*/
972         if (package->ime) {
973                 ime_x *ime = package->ime;
974                 ime_x *tmp = NULL;
975                 while(ime != NULL) {
976                         tmp = ime->next;
977                         __ps_free_ime(ime);
978                         ime = tmp;
979                 }
980         }
981         /*Free Compatibility*/
982         if (package->compatibility) {
983                 compatibility_x *compatibility = package->compatibility;
984                 compatibility_x *tmp = NULL;
985                 while(compatibility != NULL) {
986                         tmp = compatibility->next;
987                         __ps_free_compatibility(compatibility);
988                         compatibility = tmp;
989                 }
990         }
991         /*Free DeviceProfile*/
992         if (package->deviceprofile) {
993                 deviceprofile_x *deviceprofile = package->deviceprofile;
994                 deviceprofile_x *tmp = NULL;
995                 while(deviceprofile != NULL) {
996                         tmp = deviceprofile->next;
997                         __ps_free_deviceprofile(deviceprofile);
998                         deviceprofile = tmp;
999                 }
1000         }
1001         free((void*)package);
1002         package = NULL;
1003         return;
1004 }
1005