refree.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: refree.c /main/1 1996/04/21 19:24:08 drk $ */
  24. /*
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  26. * (c) Copyright 1993, 1994 International Business Machines Corp.
  27. * (c) Copyright 1993, 1994 Novell, Inc.
  28. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  29. */
  30. #include <time.h>
  31. #include <stdlib.h>
  32. #include "rerule.h"
  33. #define RE_DAILY(re) (re->re_data.re_daily)
  34. #define RE_WEEKLY(re) (re->re_data.re_weekly)
  35. #define RE_MONTHLY(re) (re->re_data.re_monthly)
  36. #define RE_YEARLY(re) (re->re_data.re_yearly)
  37. /*
  38. * Deallocate a RepeatEvent structure.
  39. */
  40. void
  41. _DtCm_free_re(
  42. RepeatEvent *re)
  43. {
  44. int i;
  45. if (!re) return;
  46. switch (re->re_type) {
  47. case RT_MINUTE:
  48. break;
  49. case RT_DAILY:
  50. if (RE_DAILY(re)->dd_ntime)
  51. free(RE_DAILY(re)->dd_time);
  52. if (RE_DAILY(re))
  53. free (RE_DAILY(re));
  54. break;
  55. case RT_WEEKLY:
  56. if (RE_WEEKLY(re)->wd_ndaytime) {
  57. for (i = 0; i < RE_WEEKLY(re)->wd_ndaytime; i++) {
  58. if (RE_WEEKLY(re)->wd_daytime[i].dt_ntime)
  59. free(
  60. RE_WEEKLY(re)->wd_daytime[i].dt_time);
  61. }
  62. free(RE_WEEKLY(re)->wd_daytime);
  63. }
  64. if (RE_WEEKLY(re))
  65. free (RE_WEEKLY(re));
  66. break;
  67. case RT_MONTHLY_POSITION:
  68. if (RE_MONTHLY(re)->md_nitems) {
  69. for (i = 0; i < RE_MONTHLY(re)->md_nitems; i++) {
  70. if (RE_MONTHLY(re)->md_weektime[i].wdt_nday)
  71. free(RE_MONTHLY(re)->
  72. md_weektime[i].wdt_day);
  73. if (RE_MONTHLY(re)->md_weektime[i].wdt_ntime)
  74. free(RE_MONTHLY(re)->
  75. md_weektime[i].wdt_time);
  76. if (RE_MONTHLY(re)->md_weektime[i].wdt_nweek)
  77. free(RE_MONTHLY(re)->
  78. md_weektime[i].wdt_week);
  79. }
  80. free(RE_MONTHLY(re)->md_weektime);
  81. }
  82. if (RE_MONTHLY(re))
  83. free (RE_MONTHLY(re));
  84. break;
  85. case RT_MONTHLY_DAY:
  86. if (RE_MONTHLY(re)->md_nitems)
  87. free(RE_MONTHLY(re)->md_days);
  88. if (RE_MONTHLY(re))
  89. free (RE_MONTHLY(re));
  90. break;
  91. case RT_YEARLY_MONTH:
  92. case RT_YEARLY_DAY:
  93. if (RE_YEARLY(re)->yd_nitems)
  94. free(RE_YEARLY(re)->yd_items);
  95. if (RE_YEARLY(re))
  96. free(RE_YEARLY(re));
  97. break;
  98. }
  99. free(re);
  100. }
  101. /*
  102. * Deallocate a RepeatEventState structure.
  103. */
  104. void
  105. _DtCm_free_re_state(
  106. RepeatEventState *res)
  107. {
  108. if (!res) return;
  109. free(res);
  110. }