handle NULL text

This commit is contained in:
Rongsong Shen 2025-04-27 17:52:42 +08:00
parent 07e2126e25
commit 3a7ae150b8
4 changed files with 20 additions and 6 deletions

View file

@ -27,6 +27,7 @@ struct Book $C.mapname("book_t") {
publish @6: Publish;
nulldata @7: Nulldata;
magic1 @2: List(UInt32) $C.mapname("magic_1") $C.maplistcount("n_magic1");
description @8: Text;
acquire :union $C.mapuniontag("acquire_method") {
buy @3: Text;
donation @4: Text;

View file

@ -30,6 +30,7 @@ typedef struct {
nulldata_t *nulldata;
int n_magic1;
uint32_t *magic_1;
char *description;
int acquire_method;
union {
char *buy;

View file

@ -48,6 +48,7 @@ int encode() {
book.nulldata = NULL;
book.n_magic1 = 2;
book.magic_1 = &magic1[0];
book.description = NULL;
book.acquire_method = Book_acquire_buy;
book.acquire.buy = "bought from Xinhua book store";