fix the maintain of oneof_field in type.

This commit is contained in:
Xavier Wang
2022-11-29 21:34:24 +08:00
parent baac866bb9
commit 2a2b0b9511
4 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
steps:
- name: Install LCov
run: |
sudo apt install libperlio-gzip-perl libjson-perl
sudo apt install libperlio-gzip-perl libjson-perl libcapture-tiny-perl
wget "https://github.com/linux-test-project/lcov/archive/master.zip"
unzip "master.zip"
cd "lcov-master"
+2
View File
@@ -15,6 +15,8 @@
*.pdb
*.rock
*.so
*.o
*.gc*
google
lua*/
out*
+4 -2
View File
@@ -1169,8 +1169,10 @@ typedef enum {USE_FIELD = 1, USE_REPEAT = 2, USE_MESSAGE = 4} lpb_DefFlags;
static void lpb_pushtypetable(lua_State *L, lpb_State *LS, const pb_Type *t);
static void lpb_newmsgtable(lua_State *L, const pb_Type *t)
{ lua_createtable(L, 0, t->field_count - t->oneof_field + t->oneof_count*2); }
static void lpb_newmsgtable(lua_State *L, const pb_Type *t) {
int fieldcnt = t->field_count - t->oneof_field + t->oneof_count*2;
lua_createtable(L, 0, fieldcnt > 0 ? fieldcnt : 0);
}
LUALIB_API const pb_Type *lpb_type(lpb_State *LS, pb_Slice s) {
const pb_Type *t;
+4 -1
View File
@@ -1323,7 +1323,10 @@ PB_API void pb_delfield(pb_State *S, pb_Type *t, pb_Field *f) {
tf = (pb_FieldEntry*)pb_gettable(&t->field_tags, (pb_Key)f->number);
if (nf && nf->value == f) nf->entry.key = 0, nf->value = NULL, ++count;
if (tf && tf->value == f) tf->entry.key = 0, tf->value = NULL, ++count;
if (count) pbT_freefield(S, f), --t->field_count;
if (count) {
if (f->oneof_idx) --t->oneof_field;
pbT_freefield(S, f), --t->field_count;
}
pb_delsort(t);
}