possible fix for some errors with vector, and fixed ARC_Text_SetString memory leak
This commit is contained in:
parent
1450bb7c86
commit
bb67a87451
2 changed files with 11 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue