GLK: TADS: Fix Memset on Non-Trivial Structure GCC Compiler Warnings

This commit is contained in:
D G Turner 2021-03-23 06:33:51 +00:00
parent 9166871942
commit 5814df1022
2 changed files with 11 additions and 2 deletions

View File

@ -1541,7 +1541,9 @@ int re_compile_and_search(re_context *ctx,
re_save_search_str(ctx, searchstr, searchlen);
/* clear the group registers */
memset(ctx->regs, 0, sizeof(ctx->regs));
for (uint i = 0; i < ARRAYSIZE(ctx->regs); i++) {
ctx->regs[i].clear();
}
/*
* search for the pattern in our copy of the string - use the copy
@ -1573,7 +1575,9 @@ int re_compile_and_match(re_context *ctx,
re_save_search_str(ctx, searchstr, searchlen);
/* clear the group registers */
memset(ctx->regs, 0, sizeof(ctx->regs));
for (uint i = 0; i < ARRAYSIZE(ctx->regs); i++) {
ctx->regs[i].clear();
}
/* match the string */
return re_match(ctx, ctx->strbuf, ctx->strbuf, ctx->curlen,

View File

@ -52,6 +52,11 @@ typedef struct _re_group_register
const char *end_ofs;
_re_group_register() : start_ofs(nullptr), end_ofs(nullptr) {}
void clear() {
start_ofs = nullptr;
end_ofs = nullptr;
}
} re_group_register;
/* number of group registers we keep */