diff --git a/src/graphics/sdl/text.c b/src/graphics/sdl/text.c index 0cd81d2..9d65ed9 100644 --- a/src/graphics/sdl/text.c +++ b/src/graphics/sdl/text.c @@ -32,6 +32,9 @@ void ARC_Text_SetString(ARC_Text *text, ARC_Renderer *renderer, ARC_String *stri text->bounds.w = surface->w; text->bounds.h = surface->h; + if(text->texture){ + SDL_DestroyTexture(text->texture); + } text->texture = SDL_CreateTextureFromSurface((SDL_Renderer *)renderer, surface); SDL_FreeSurface(surface); diff --git a/src/std/vector.c b/src/std/vector.c index 483fd4b..7e9158b 100644 --- a/src/std/vector.c +++ b/src/std/vector.c @@ -14,7 +14,7 @@ void ARC_Vector_Create(ARC_Vector **vector){ *vector = (ARC_Vector *) malloc(sizeof(ARC_Vector)); (*vector)->currentSize = (uint32_t *)malloc(sizeof(uint32_t)); (*vector)->capacity = (uint32_t *)malloc(sizeof(uint32_t)); - (*vector)->data = (void *)malloc(sizeof(void *)); + (*vector)->data = (void **)malloc(sizeof(void *)); *(*vector)->currentSize = 0; *(*vector)->capacity = 1; @@ -77,6 +77,9 @@ void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t *index){ void ARC_Vector_RemoveIndexNoCheck(ARC_Vector *vector, uint32_t *index){ for(uint32_t i = *index; i <= *vector->currentSize; i++){ + if(i + 1 >= *vector->currentSize - 1){ + break; + } vector->data[i] = vector->data[i + 1]; } @@ -87,6 +90,10 @@ void ARC_Vector_RemoveIndexNoCheck(ARC_Vector *vector, uint32_t *index){ } *vector->capacity >>= 1; + if(*vector->capacity <= 0){ + *vector->capacity = 1; + } + vector->data = (void *)realloc(vector->data, sizeof(void *) * *vector->capacity); }