Ver Fonte

save another 6k bytes (20k free when game starts)

jblanked há 9 meses atrás
pai
commit
86272e2132
2 ficheiros alterados com 9 adições e 2 exclusões
  1. 8 1
      game/icon.c
  2. 1 1
      game/icon.h

+ 8 - 1
game/icon.c

@@ -94,7 +94,14 @@ static IconContext *icon_generic_alloc(const char *id, const Icon *icon, uint8_t
         FURI_LOG_E("Game", "Failed to allocate IconContext");
         return NULL;
     }
-    snprintf(ctx->id, sizeof(ctx->id), "%s", id);
+    ctx->id = malloc(strlen(id) + 1);
+    if (!ctx->id)
+    {
+        FURI_LOG_E("Game", "Failed to allocate IconContext id");
+        free(ctx);
+        return NULL;
+    }
+    snprintf(ctx->id, strlen(id) + 1, "%s", id);
     ctx->icon = icon;
     ctx->size = (Vector){width, height};
     return ctx;

+ 1 - 1
game/icon.h

@@ -4,7 +4,7 @@
 
 typedef struct
 {
-    char id[20];
+    char *id;
     const Icon *icon;
     Vector size;
 } IconContext;