Skip to content

Commit 858ed7a

Browse files
authored
Merge pull request cstack#32 from kodemartin/walkthrough-revisions-fixes
Various fixes and revisions
2 parents 7ed8a18 + ea1152c commit 858ed7a

File tree

10 files changed

+391
-336
lines changed

10 files changed

+391
-336
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,4 @@ DEPENDENCIES
261261
rspec
262262

263263
BUNDLED WITH
264-
1.16.3
264+
2.0.1

_parts/part1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Finally, we parse and execute the command. There is only one recognized command
154154

155155
```c
156156
if (strcmp(input_buffer->buffer, ".exit") == 0) {
157+
close_input_buffer(input_buffer);
157158
exit(EXIT_SUCCESS);
158159
} else {
159160
printf("Unrecognized command '%s'.\n", input_buffer->buffer);

_parts/part10.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ with a new recursive function that takes any node, then prints it and its childr
377377
+ child = *internal_node_child(node, i);
378378
+ print_tree(pager, child, indentation_level + 1);
379379
+
380-
+ indent(indentation_level);
380+
+ indent(indentation_level + 1);
381381
+ printf("- key %d\n", *internal_node_key(node, i));
382382
+ }
383383
+ child = *internal_node_right_child(node);
@@ -420,7 +420,7 @@ Here's a test case for the new printing functionality!
420420
+ " - 5",
421421
+ " - 6",
422422
+ " - 7",
423-
+ "- key 7",
423+
+ " - key 7",
424424
+ " - leaf (size 7)",
425425
+ " - 8",
426426
+ " - 9",

_parts/part2.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,13 @@ The skeleton of our database is taking shape... wouldn't it be nice if it stored
176176
InputBuffer* new_input_buffer() {
177177
InputBuffer* input_buffer = malloc(sizeof(InputBuffer));
178178
input_buffer->buffer = NULL;
179-
@@ -35,16 +52,66 @@ void read_input(InputBuffer* input_buffer) {
180-
input_buffer->buffer[bytes_read - 1] = 0;
179+
@@ -40,17 +57,67 @@ void close_input_buffer(InputBuffer* input_buffer) {
180+
free(input_buffer);
181181
}
182182

183183
+MetaCommandResult do_meta_command(InputBuffer* input_buffer) {
184184
+ if (strcmp(input_buffer->buffer, ".exit") == 0) {
185+
+ close_input_buffer(input_buffer);
185186
+ exit(EXIT_SUCCESS);
186187
+ } else {
187188
+ return META_COMMAND_UNRECOGNIZED_COMMAND;
@@ -220,6 +221,7 @@ The skeleton of our database is taking shape... wouldn't it be nice if it stored
220221
read_input(input_buffer);
221222

222223
- if (strcmp(input_buffer->buffer, ".exit") == 0) {
224+
- close_input_buffer(input_buffer);
223225
- exit(EXIT_SUCCESS);
224226
- } else {
225227
- printf("Unrecognized command '%s'.\n", input_buffer->buffer);
@@ -247,4 +249,4 @@ The skeleton of our database is taking shape... wouldn't it be nice if it stored
247249
+ printf("Executed.\n");
248250
}
249251
}
250-
```
252+
```

0 commit comments

Comments
 (0)