Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit b1b90d8

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Create arrays of strings correctly in C89
1 parent a36d08f commit b1b90d8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

SimulationRuntime/c/util/string_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,6 @@ void unpack_string_array(const string_array_t *a, const char **data)
956956
size_t sz = base_array_nr_of_elements(*a);
957957
long i;
958958
for (i=0; i<sz; i++) {
959-
data[i] = mmc_mk_scon(data[i]);
959+
((void**)a->data)[i] = mmc_mk_scon(data[i]);
960960
}
961961
}

SimulationRuntime/c/util/utility.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,15 @@ extern int OpenModelica_regexImpl(const char* str, const char* re, const int max
126126
return nmatch;
127127
}
128128

129+
static char* Modelica_strdup(const char *str)
130+
{
131+
char *res = ModelicaAllocateString(strlen(str));
132+
strcpy(res, str);
133+
}
134+
129135
extern int OpenModelica_regex(const char* str, const char* re, int maxn, int extended, int sensitive, const char **outMatches)
130136
{
131-
return OpenModelica_regexImpl(str,re,maxn,extended,sensitive,(void*(*)(const char*)) mmc_mk_scon,(void**)outMatches);
137+
return OpenModelica_regexImpl(str,re,maxn,extended,sensitive,(void*(*)(const char*)) Modelica_strdup,(void**)outMatches);
132138
}
133139

134140
#endif /* OMC_MINIMAL_RUNTIME */

0 commit comments

Comments
 (0)