Skip to content

Commit

Permalink
fix: treat name as array of chars instead of pointer to heap address
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Jun 8, 2024
1 parent 00e8f43 commit aad86f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tools/skap/include/skap_idx_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
#include <raylib.h>
#include <skap_defines.h>

#define SKAP_IDX_IMAGE_MD_NAME_MAX_LEN 512

typedef struct {
const char *name;
char name[SKAP_IDX_IMAGE_MD_NAME_MAX_LEN];
u32 width;
u32 height;
u32 mipmaps;
Expand Down
7 changes: 5 additions & 2 deletions tools/skap/src/skap_idx_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


#include <assert.h>
#include <string.h>
#include <skap_idx_image.h>

void skap_idx_image_loadall(Image *imgs, const char **img_paths, usz size) {
Expand All @@ -37,9 +38,8 @@ void skap_idx_image_unloadall(Image *imgs, usz size) {
}

skap_idx_image skap_idx_image_create(const char *name, Image *img) {
return (skap_idx_image) {
skap_idx_image i = {
.metadata = (skap_idx_image_md) {
.name = name,
.width = img->width,
.height = img->height,
.mipmaps = img->mipmaps,
Expand All @@ -48,6 +48,9 @@ skap_idx_image skap_idx_image_create(const char *name, Image *img) {
.blob_offset = 0,
.blob_size = 0
};
memset(i.metadata.name, 0, sizeof(i.metadata.name));
strncpy(i.metadata.name, name, sizeof(i.metadata.name) - 1);
return i;
}

u8 skap_idx_image_append(FILE *fd, skap_idx_image *i) {
Expand Down

0 comments on commit aad86f6

Please sign in to comment.