diff --git a/cmd/wuffs-c/internal/cgen/expr.go b/cmd/wuffs-c/internal/cgen/expr.go index 62ee3964..67d9f081 100644 --- a/cmd/wuffs-c/internal/cgen/expr.go +++ b/cmd/wuffs-c/internal/cgen/expr.go @@ -107,34 +107,24 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error { } qid := recvTyp.QID() - // Generate a 2 or 3 part expression using the comma operator: - // "(memset call, check_wuffs_version call, return_empty_struct - // call)". The final part is a function call (to a static inline - // function) instead of a struct literal, to avoid a "expression - // result unused" compiler error. - // - // The middle part, the check_wuffs_version call, is optional, for - // some built-in types. - - // TODO: drop the memset and the WUFFS_INITIALIZE__ALREADY_ZEROED. - - b.printf("(memset(%s", addr) - // TODO: ensure that the recv expression is idempotent. - if err := g.writeExpr(b, recv, depth); err != nil { - return err - } - b.printf(", 0, sizeof (%s%s))", g.packagePrefix(qid), qid[1].Str(g.tm)) - if isBaseRangeType(qid) { - b.writes(", wuffs_base__return_empty_struct())") + // Generate a 2 part expression using the comma operator: "(memset + // call, return_empty_struct call)". The final part is a function + // call (to a static inline function) instead of a struct literal, + // to avoid a "expression result unused" compiler error. + b.printf("(memset(%s", addr) + if err := g.writeExpr(b, recv, depth); err != nil { + return err + } + b.printf(", 0, sizeof (%s%s)), wuffs_base__return_empty_struct())", + g.packagePrefix(qid), qid[1].Str(g.tm)) } else { - b.printf(", wuffs_base__ignore_status("+ + b.printf("wuffs_base__ignore_status("+ "%s%s__initialize(%s", g.packagePrefix(qid), qid[1].Str(g.tm), addr) if err := g.writeExpr(b, recv, depth); err != nil { return err } - b.printf(", sizeof (%s%s), WUFFS_VERSION, WUFFS_INITIALIZE__ALREADY_ZEROED)))", - g.packagePrefix(qid), qid[1].Str(g.tm)) + b.printf(", sizeof (%s%s), WUFFS_VERSION, 0))", g.packagePrefix(qid), qid[1].Str(g.tm)) } return nil diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index b492027a..799fe09a 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -10406,10 +10406,9 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self, .len = 1024, })); if (self->private_impl.f_previous_lzw_decode_ended_abruptly) { - (memset(&self->private_data.f_lzw, 0, sizeof(wuffs_lzw__decoder)), - wuffs_base__ignore_status(wuffs_lzw__decoder__initialize( - &self->private_data.f_lzw, sizeof(wuffs_lzw__decoder), WUFFS_VERSION, - WUFFS_INITIALIZE__ALREADY_ZEROED))); + wuffs_base__ignore_status(wuffs_lzw__decoder__initialize( + &self->private_data.f_lzw, sizeof(wuffs_lzw__decoder), WUFFS_VERSION, + 0)); } { WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);