lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Em seg., 9 de nov. de 2020 às 13:48, Luiz Henrique de Figueiredo <> escreveu:
> -  for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
> +  memset(g->mt, 0, sizeof(struct Table *) * (size_t) LUA_NUMTAGS);

No. The C standard says that NULL does not need to have all bits zero.
Change 0 by NULL, after the memset, the memory has the same content.
-  for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
+  memset(g->mt, NULL, sizeof(struct Table *) * (size_t) LUA_NUMTAGS);

Internally, memset has its own loop, but this is very highly optimized for the platform used.

Ranier Vilela