Refactor sv_init
This commit is contained in:
parent
3e68bbbef5
commit
9e823f892c
1 changed files with 4 additions and 6 deletions
|
@ -9,12 +9,11 @@ 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) {
|
||||
if(sv->data) {
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue