Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
engboris committed Jun 20, 2024
1 parent 11dbc34 commit 231f0e7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -12872,15 +12872,15 @@ output_internal_function (struct cb_program *prog, cb_tree parameter_list)

if (prog->flag_inspect_used) {
output_line ("if (inspect_st != NULL)");
output_line ("\tcob_free (inspect_st);");
output_line ("\tcob_inspect_free (inspect_st);");
}
if (prog->flag_string_used) {
output_line ("if (string_st != NULL)");
output_line ("\tcob_free (string_st);");
output_line ("\tcob_string_free (string_st);");
}
if (prog->flag_unstring_used) {
output_line ("if (unstring_st != NULL)");
output_line ("\tcob_free (unstring_st);");
output_line ("\tcob_unstring_free (unstring_st);");
}

if (prog->flag_main) {
Expand Down
3 changes: 3 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1954,19 +1954,22 @@ COB_EXPIMP void cob_inspect_trailing_r (cob_inspect_state *, cob_field *, cob_fi
COB_EXPIMP void cob_inspect_converting_r (cob_inspect_state *, const cob_field *, const cob_field *);
COB_EXPIMP void cob_inspect_translating_r (cob_inspect_state *, const unsigned char *);
COB_EXPIMP void cob_inspect_finish_r (cob_inspect_state *);
COB_EXPIMP void cob_inspect_free (cob_inspect_state *);

/* Thread-safe string */
COB_EXPIMP void cob_string_init_r (cob_string_state **, cob_field *, cob_field *);
COB_EXPIMP void cob_string_delimited_r (cob_string_state *, cob_field *);
COB_EXPIMP void cob_string_append_r (cob_string_state *, cob_field *);
COB_EXPIMP void cob_string_finish_r (cob_string_state *);
COB_EXPIMP void cob_string_free (cob_string_state *);

/* Thread-safe unstring */
COB_EXPIMP void cob_unstring_init_r (cob_unstring_state **, cob_field *, cob_field *, const size_t);
COB_EXPIMP void cob_unstring_delimited_r (cob_unstring_state *, cob_field *, const cob_u32_t);
COB_EXPIMP void cob_unstring_into_r (cob_unstring_state *, cob_field *, cob_field *, cob_field *);
COB_EXPIMP void cob_unstring_tallying_r (cob_unstring_state *, cob_field *);
COB_EXPIMP void cob_unstring_finish_r (cob_unstring_state *);
COB_EXPIMP void cob_unstring_free (cob_unstring_state *);

/* Compat-only functions for old programs */
COB_EXPIMP void cob_inspect_init (cob_field *, const cob_u32_t);
Expand Down
55 changes: 37 additions & 18 deletions libcob/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,31 +1301,50 @@ cob_unstring_finish (void)
/* Initialization/Termination */

void
cob_exit_strings ()
cob_inspect_free (struct cob_inspect_state *st)
{
struct cob_inspect_state *sti = share_inspect_state;
struct cob_unstring_state *stu = share_unstring_state;

if (sti != NULL) {
if (sti->mark) {
cob_free (sti->mark);
sti->mark = NULL;
if (st != NULL) {
if (st->mark) {
cob_free (st->mark);
st->mark = NULL;
}
sti->mark_size = sti->mark_min = sti->mark_max = 0;
if (sti->repdata) {
cob_free (sti->repdata);
sti->repdata = NULL;
st->mark_size = st->mark_min = st->mark_max = 0;
if (st->repdata) {
cob_free (st->repdata);
st->repdata = NULL;
}
sti->repdata_size = 0;
st->repdata_size = 0;
}
}

void
cob_string_free (struct cob_string_state *st)
{
cob_free (st->dst);
cob_free (st->ptr);
cob_free (st->dlm);
}

if (stu != NULL) {
if (stu->dlm_list) {
cob_free (stu->dlm_list);
stu->dlm_list = NULL;
void
cob_unstring_free (struct cob_unstring_state *st)
{
if (st != NULL) {
if (st->dlm_list) {
cob_free (st->dlm_list);
st->dlm_list = NULL;
st->dlm_list_size = 0;
}
stu->dlm_list_size = 0;
}
}

void
cob_exit_strings ()
{
struct cob_inspect_state *sti = share_inspect_state;
struct cob_unstring_state *stu = share_unstring_state;

cob_inspect_free (sti);
cob_unstring_free (stu);

if (figurative_ptr) {
cob_free (figurative_ptr);
Expand Down

0 comments on commit 231f0e7

Please sign in to comment.