Skip to content

Commit 4d26b26

Browse files
authored
Merge pull request cstack#29 from nilesr/master
Fix if statement based off of uninitialized value in part3
2 parents 02a1a79 + c3d5432 commit 4d26b26

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

_parts/part3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Lastly, we need to initialize the table and handle a few more error cases:
185185

186186
```diff
187187
+ Table* new_table() {
188-
+ Table* table = malloc(sizeof(Table));
188+
+ Table* table = calloc(sizeof(Table));
189189
+ table->num_rows = 0;
190190
+
191191
+ return table;
@@ -334,7 +334,7 @@ We'll address those issues in the next part. For now, here's the complete diff f
334334
+}
335335
+
336336
+Table* new_table() {
337-
+ Table* table = malloc(sizeof(Table));
337+
+ Table* table = calloc(sizeof(Table));
338338
+ table->num_rows = 0;
339339
+
340340
+ return table;
@@ -426,4 +426,4 @@ We'll address those issues in the next part. For now, here's the complete diff f
426426
+ }
427427
}
428428
}
429-
```
429+
```

_parts/part5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ I'm renaming `new_table()` to `db_open()` because it now has the effect of openi
6666
+ Pager* pager = pager_open(filename);
6767
+ uint32_t num_rows = pager->file_length / ROW_SIZE;
6868
+
69-
Table* table = malloc(sizeof(Table));
69+
Table* table = calloc(sizeof(Table));
7070
- table->num_rows = 0;
7171
+ table->pager = pager;
7272
+ table->num_rows = num_rows;
@@ -413,7 +413,7 @@ Until then!
413413
+ Pager* pager = pager_open(filename);
414414
+ uint32_t num_rows = pager->file_length / ROW_SIZE;
415415
+
416-
Table* table = malloc(sizeof(Table));
416+
Table* table = calloc(sizeof(Table));
417417
- table->num_rows = 0;
418418
+ table->pager = pager;
419419
+ table->num_rows = num_rows;

0 commit comments

Comments
 (0)