fix incorrect swap of source/dest var in decode list
This commit is contained in:
parent
c582108917
commit
e1013e038b
4 changed files with 12 additions and 12 deletions
|
|
@ -18,9 +18,9 @@ struct Publish $C.mapname("publish_t") {
|
|||
struct Book $C.mapname("book_t") {
|
||||
title @0: Text;
|
||||
authors @1: List(Text) $C.mapname("authors") $C.maplistcount("n_authors");
|
||||
chapters @5: List(Chapter) $C.maplistcount("n_chapters");
|
||||
chapters @5: List(Chapter) $C.mapname("chapters_") $C.maplistcount("n_chapters");
|
||||
publish @6: Publish;
|
||||
magic1 @2: List(UInt32) $C.maplistcount("n_magic1");
|
||||
magic1 @2: List(UInt32) $C.mapname("magic_1") $C.maplistcount("n_magic1");
|
||||
acquire :union $C.mapuniontag("acquire_method") {
|
||||
buy @3: Text;
|
||||
donation @4: Text;
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ typedef struct {
|
|||
int n_authors;
|
||||
char **authors;
|
||||
int n_chapters;
|
||||
chapter_t *chapters;
|
||||
chapter_t *chapters_;
|
||||
publish_t publish;
|
||||
int n_magic1;
|
||||
uint32_t *magic1;
|
||||
uint32_t *magic_1;
|
||||
int acquire_method;
|
||||
union {
|
||||
char *buy;
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ int encode() {
|
|||
book.n_authors = 2;
|
||||
book.authors = authors;
|
||||
book.n_chapters = 3;
|
||||
book.chapters = &chapters[0];
|
||||
book.chapters_ = &chapters[0];
|
||||
memcpy(&(book.publish), &publish, sizeof(publish));
|
||||
book.n_magic1 = 2;
|
||||
book.magic1 = &magic1[0];
|
||||
book.magic_1 = &magic1[0];
|
||||
book.acquire_method = Book_acquire_buy;
|
||||
book.acquire.buy = "bought from Xinhua book store";
|
||||
|
||||
|
|
@ -85,10 +85,10 @@ int decode() {
|
|||
|
||||
printf("chapters(%d):\n", book.n_chapters);
|
||||
for(i = 0; i < book.n_chapters; i ++) {
|
||||
printf("\tcaption: %s\n", book.chapters[i].caption);
|
||||
printf("\tcaption: %s\n", book.chapters_[i].caption);
|
||||
printf("\tfrom %d to %d\n",
|
||||
book.chapters[i].start,
|
||||
book.chapters[i].end);
|
||||
book.chapters_[i].start,
|
||||
book.chapters_[i].end);
|
||||
}
|
||||
|
||||
printf("ISBN: %lu year: %u\n",
|
||||
|
|
@ -97,7 +97,7 @@ int decode() {
|
|||
|
||||
printf("magic1:\n");
|
||||
for(i = 0; i < book.n_magic1; i ++) {
|
||||
printf("\t%d\n", book.magic1[i]);
|
||||
printf("\t%d\n", book.magic_1[i]);
|
||||
}
|
||||
|
||||
if (book.acquire_method == Book_acquire_buy) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue