Skip to content

Commit

Permalink
Create arrays of strings correctly in C89
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Feb 7, 2017
1 parent a36d08f commit b1b90d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SimulationRuntime/c/util/string_array.c
Expand Up @@ -956,6 +956,6 @@ void unpack_string_array(const string_array_t *a, const char **data)
size_t sz = base_array_nr_of_elements(*a);
long i;
for (i=0; i<sz; i++) {
data[i] = mmc_mk_scon(data[i]);
((void**)a->data)[i] = mmc_mk_scon(data[i]);
}
}
8 changes: 7 additions & 1 deletion SimulationRuntime/c/util/utility.c
Expand Up @@ -126,9 +126,15 @@ extern int OpenModelica_regexImpl(const char* str, const char* re, const int max
return nmatch;
}

static char* Modelica_strdup(const char *str)
{
char *res = ModelicaAllocateString(strlen(str));
strcpy(res, str);
}

extern int OpenModelica_regex(const char* str, const char* re, int maxn, int extended, int sensitive, const char **outMatches)
{
return OpenModelica_regexImpl(str,re,maxn,extended,sensitive,(void*(*)(const char*)) mmc_mk_scon,(void**)outMatches);
return OpenModelica_regexImpl(str,re,maxn,extended,sensitive,(void*(*)(const char*)) Modelica_strdup,(void**)outMatches);
}

#endif /* OMC_MINIMAL_RUNTIME */

0 comments on commit b1b90d8

Please sign in to comment.