From f24c66ae577514f70489a8e7537a77842e07f841 Mon Sep 17 00:00:00 2001 From: Filip Jorissen Date: Sat, 15 Jun 2024 17:10:34 +0200 Subject: [PATCH] fixes and revision history for #1891 --- IBPSA/Resources/C-Sources/WeeklySchedule.c | 20 +++++++++++++++++++ .../Resources/C-Sources/WeeklyScheduleFree.c | 12 ++--------- .../C-Sources/WeeklyScheduleGetValue.c | 13 +++--------- IBPSA/Utilities/IO/Files/WeeklySchedule.mo | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/IBPSA/Resources/C-Sources/WeeklySchedule.c b/IBPSA/Resources/C-Sources/WeeklySchedule.c index 8348c84b5d..519af8d833 100644 --- a/IBPSA/Resources/C-Sources/WeeklySchedule.c +++ b/IBPSA/Resources/C-Sources/WeeklySchedule.c @@ -3,6 +3,8 @@ This code implements a weekly schedule. Changelog: + June 15, 2024 by Filip Jorissen, Builtwins + Revisions for #1891: compliance with Modelica include annotation rules. April 9, 2024 by Filip Jorissen, Builtwins Revisions for #1869 to remove a header requirement that contains the number of rows/columns. March 30, 2024 by Filip Jorissen, Builtwins @@ -416,4 +418,22 @@ void* weeklyScheduleInit(const int tableOnFile, const char* name, const double t return (void*) scheduleID; } + +void weeklyScheduleFreeInit(void * ID) { + WeeklySchedule* scheduleID = (WeeklySchedule*)ID; + + if (scheduleID->lastData != NULL) + free(scheduleID->lastData); + + if (scheduleID->token != NULL) + free(scheduleID->token); + + if (scheduleID->fp != NULL) + fclose(scheduleID->fp); + + if (scheduleID->buff2 != NULL) + free(scheduleID->buff2); + +} + #endif diff --git a/IBPSA/Resources/C-Sources/WeeklyScheduleFree.c b/IBPSA/Resources/C-Sources/WeeklyScheduleFree.c index f9e1c644e8..63f863b7e5 100644 --- a/IBPSA/Resources/C-Sources/WeeklyScheduleFree.c +++ b/IBPSA/Resources/C-Sources/WeeklyScheduleFree.c @@ -3,16 +3,8 @@ This code implements a weekly schedule. Changelog: - April 9, 2024 by Filip Jorissen, Builtwins - Revisions for #1869 to remove a header requirement that contains the number of rows/columns. - March 30, 2024 by Filip Jorissen, Builtwins - Revisions for #1860 to avoid memory leaks when calling ModelicaFormatError. - May 25, 2022 by Michael Wetter, LBNL - Refactored to comply with C89. - March 9, 2022 by Filip Jorissen, KU Leuven - Initial version. - April 10, 2022 by Filip Jorissen, KU Leuven - Added tableOnFile option. + June 15, 2024 by Filip Jorissen, Builtwins + Initial version for #1891: compliance with Modelica include annotation rules. */ diff --git a/IBPSA/Resources/C-Sources/WeeklyScheduleGetValue.c b/IBPSA/Resources/C-Sources/WeeklyScheduleGetValue.c index 51dfef5fa4..96098df26d 100644 --- a/IBPSA/Resources/C-Sources/WeeklyScheduleGetValue.c +++ b/IBPSA/Resources/C-Sources/WeeklyScheduleGetValue.c @@ -3,19 +3,12 @@ This code implements a weekly schedule. Changelog: - April 9, 2024 by Filip Jorissen, Builtwins - Revisions for #1869 to remove a header requirement that contains the number of rows/columns. - March 30, 2024 by Filip Jorissen, Builtwins - Revisions for #1860 to avoid memory leaks when calling ModelicaFormatError. - May 25, 2022 by Michael Wetter, LBNL - Refactored to comply with C89. - March 9, 2022 by Filip Jorissen, KU Leuven - Initial version. - April 10, 2022 by Filip Jorissen, KU Leuven - Added tableOnFile option. + June 15, 2024 by Filip Jorissen, Builtwins + Initial version for #1891: compliance with Modelica include annotation rules. */ + #include #include #include diff --git a/IBPSA/Utilities/IO/Files/WeeklySchedule.mo b/IBPSA/Utilities/IO/Files/WeeklySchedule.mo index 0325cc119f..5d50098b40 100644 --- a/IBPSA/Utilities/IO/Files/WeeklySchedule.mo +++ b/IBPSA/Utilities/IO/Files/WeeklySchedule.mo @@ -40,7 +40,7 @@ protected input Real timeIn "Time for look-up"; output Real y "Schedule value"; external "C" y=getScheduleValue(ID, iCol, timeIn) - annotation(Include="#include ", + annotation(Include="#include ", IncludeDirectory="modelica://IBPSA/Resources/C-Sources"); end getCalendarValue;