Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Vector_set(Vector *vector, size_t index, const char *str) {
- // char * temp;
- // Perform safety asserts
- assert(vector);
- assert(str);
- assert(index >= 0);
- // If there's currently something at the vector in that spot, we'll override it.
- /*
- if(vector->array[index]) {
- free(vector->array[index]);
- vector->array[index] = NULL;
- }
- // Perform the copy
- vector->array[index] = malloc(strlen(str)+1);
- */
- if(vector->array[index]) {
- vector->array[index] = (char *) realloc(vector->array[index], strlen(str)+1);
- }
- strcpy(vector->array[index], str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement