enhance to generate encode routine to be more robust to encode NULL
This commit is contained in:
parent
3425f75440
commit
07e2126e25
4 changed files with 17 additions and 1 deletions
|
|
@ -1256,7 +1256,11 @@ void mk_struct_ptr_encoder(capnp_ctx_t *ctx, struct node *n) {
|
|||
n->name.str, n->name.str, buf);
|
||||
str_addf(&(ctx->SRC), "\t%s_ptr ptr;\n", n->name.str);
|
||||
str_addf(&(ctx->SRC), "\tstruct %s d;\n", n->name.str);
|
||||
str_addf(&(ctx->SRC), "\t%s zero_ = {0}; \n", buf);
|
||||
str_addf(&(ctx->SRC), "\tptr = new_%s(cs);\n", n->name.str);
|
||||
str_addf(&(ctx->SRC), "\tif (s == NULL) {\n");
|
||||
str_addf(&(ctx->SRC), "\t\ts = &zero_;\n");
|
||||
str_addf(&(ctx->SRC), "\t}\n");
|
||||
str_addf(&(ctx->SRC), "\tencode_%s(cs, &d, s);\n", n->name.str);
|
||||
str_addf(&(ctx->SRC), "\twrite_%s(&d, ptr);\n", n->name.str);
|
||||
str_addf(&(ctx->SRC), "\t(*p) = ptr;\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue