Quellcode durchsuchen

Fix minor issues

Kajetan Johannes Hammerle vor 11 Monaten
Ursprung
Commit
93436c1c7a
4 geänderte Dateien mit 8 neuen und 12 gelöschten Zeilen
  1. 1 1
      include/core/Utility.h
  2. 2 6
      src/Utility.c
  3. 4 4
      test/modules/TestTests.c
  4. 1 1
      test/modules/UtilityTests.c

+ 1 - 1
include/core/Utility.h

@@ -47,7 +47,7 @@ void coreFree(void* p);
 #define corePrintMemoryReport()
 #endif
 
-bool coreSleep(i64 nanos);
+bool coreSleepNanos(i64 nanos);
 i64 coreNanos(void);
 
 #endif

+ 2 - 6
src/Utility.c

@@ -195,12 +195,8 @@ void coreFreeDebug(const char* file, int line, void* p) {
     if(p == nullptr) {
         return;
     }
-    CoreMemoryInfo* rp = nullptr;
     void* w = (char*)p - sizeof(CoreMemoryInfo);
-    memcpy(&rp, &w, sizeof(rp));
-
-    // CoreMemoryInfo* rp = (CoreMemoryInfo*)((char*)p -
-    // sizeof(CoreMemoryInfo));
+    CoreMemoryInfo* rp = w;
     if(checkCanary(rp->canary)) {
         file = coreGetShortFileName(file);
         CORE_LOG_ERROR("Free at %s:%d violated pre canary", file, line);
@@ -236,7 +232,7 @@ void coreFree(void* p) {
 
 #endif
 
-bool coreSleep(i64 nanos) {
+bool coreSleepNanos(i64 nanos) {
     struct timespec t;
     t.tv_nsec = nanos % 1'000'000'000;
     t.tv_sec = nanos / 1'000'000'000;

+ 4 - 4
test/modules/TestTests.c

@@ -14,12 +14,12 @@ void coreTestTest() {
     CORE_TEST_NOT_NULL(nullptr);
     CORE_TEST_FLOAT(0.0f, 1.0f, 0.1f);
 
-    CoreVector2 a = {0, 1};
-    CoreVector2 b = {2, 3};
+    CoreVector2 a = {{0, 1}};
+    CoreVector2 b = {{2, 3}};
     CORE_TEST_V2(&a, &b);
 
-    CoreIntVector2 ia = {0, 1};
-    CoreIntVector2 ib = {2, 3};
+    CoreIntVector2 ia = {{0, 1}};
+    CoreIntVector2 ib = {{2, 3}};
     CORE_TEST_IV2(&ia, &ib);
     coreFinalizeTests();
 }

+ 1 - 1
test/modules/UtilityTests.c

@@ -58,7 +58,7 @@ static void testDegreeToRadian() {
 
 static void testSleep(i64 nanos) {
     i64 time = -coreNanos();
-    CORE_TEST_FALSE(coreSleep(nanos));
+    CORE_TEST_FALSE(coreSleepNanos(nanos));
     time += coreNanos();
     CORE_TEST_TRUE(time >= nanos && time <= (nanos * 13) / 10);
 }