mirror of https://github.com/bjornbytes/lovr.git
Minor cleanup; Fix some undefined behavior;
This commit is contained in:
parent
ec7b2c0b68
commit
f268810d2a
|
@ -97,7 +97,7 @@ static int nextEvent(lua_State* L) {
|
|||
case EVENT_THREAD_ERROR:
|
||||
luax_pushobject(L, event.data.thread.thread);
|
||||
lua_pushstring(L, event.data.thread.error);
|
||||
free((void*) event.data.thread.error);
|
||||
free(event.data.thread.error);
|
||||
return 3;
|
||||
|
||||
#ifdef LOVR_ENABLE_HEADSET
|
||||
|
|
|
@ -279,7 +279,7 @@ static int l_lovrFilesystemNewBlob(lua_State* L) {
|
|||
const char* path = luaL_checkstring(L, 1);
|
||||
uint8_t* data = lovrFilesystemRead(path, -1, &size);
|
||||
lovrAssert(data, "Could not load file '%s'", path);
|
||||
Blob* blob = lovrBlobCreate((void*) data, size, path);
|
||||
Blob* blob = lovrBlobCreate(data, size, path);
|
||||
luax_pushobject(L, blob);
|
||||
lovrRelease(Blob, blob);
|
||||
return 1;
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
struct Thread* thread;
|
||||
const char* error;
|
||||
char* error;
|
||||
} ThreadEvent;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -117,11 +117,7 @@ quat quat_fromAngleAxis(quat q, float angle, float ax, float ay, float az) {
|
|||
if (length > 0.f) {
|
||||
s /= length;
|
||||
}
|
||||
q[0] = s * ax;
|
||||
q[1] = s * ay;
|
||||
q[2] = s * az;
|
||||
q[3] = c;
|
||||
return q;
|
||||
return quat_set(q, s * ax, s * ay, s * az, c);
|
||||
}
|
||||
|
||||
quat quat_fromMat4(quat q, mat4 m) {
|
||||
|
@ -132,11 +128,7 @@ quat quat_fromMat4(quat q, mat4 m) {
|
|||
x = (m[9] - m[6]) > 0.f ? -x : x;
|
||||
y = (m[2] - m[8]) > 0.f ? -y : y;
|
||||
z = (m[4] - m[1]) > 0.f ? -z : z;
|
||||
q[0] = x;
|
||||
q[1] = y;
|
||||
q[2] = z;
|
||||
q[3] = w;
|
||||
return q;
|
||||
return quat_set(q, x, y, z, w);
|
||||
}
|
||||
|
||||
quat quat_mul(quat q, quat r) {
|
||||
|
|
|
@ -20,7 +20,7 @@ static int luax_module__gc(lua_State* L) {
|
|||
lua_getfield(L, LUA_REGISTRYINDEX, "_lovrmodules");
|
||||
for (int i = luax_len(L, 2); i >= 1; i--) {
|
||||
lua_rawgeti(L, 2, i);
|
||||
luax_destructor destructor = (luax_destructor) lua_touserdata(L, -1);
|
||||
luax_destructor destructor = (luax_destructor) lua_tocfunction(L, -1);
|
||||
destructor();
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void luax_atexit(lua_State* L, luax_destructor destructor) {
|
|||
}
|
||||
|
||||
int length = luax_len(L, -1);
|
||||
lua_pushlightuserdata(L, (void*) destructor);
|
||||
lua_pushcfunction(L, (lua_CFunction) destructor);
|
||||
lua_rawseti(L, -2, length + 1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue