Refactor sv_init

This commit is contained in:
Stephen Seo 2020-06-05 23:31:19 +09:00
parent 3e68bbbef5
commit 9e823f892c

View file

@ -9,11 +9,10 @@ typedef struct SimpleVector {
} SimpleVector;
void sv_init(SimpleVector *sv, unsigned int capacity) {
if(!sv->data) {
memset(sv, 0, sizeof(SimpleVector));
sv->data = (int*)malloc(capacity * sizeof(int));
sv->capacity = capacity;
sv->size = 0;
}
}
void sv_cleanup(SimpleVector *sv) {
@ -74,7 +73,6 @@ int is_digit_sum_equal(int a, int b) {
int main(int argc, char **argv) {
SimpleVector sv;
memset(&sv, 0, sizeof(SimpleVector));
sv_init(&sv, 32);
int temp_i;