You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Chapters/01-base64.qmd
+3-3
Original file line number
Diff line number
Diff line change
@@ -184,7 +184,7 @@ But the input string does not have enough bytes to create a fourth 6-bit group.
184
184
Every time this happens, where an entire group of 6 bits is empty,
185
185
this group becomes a "padding group". Every "padding group" is mapped to
186
186
the character `=` (equal sign), which represents "null", or, the end
187
-
of meaninful characters in the sequence. Hence, everytime that the algorithm produces a
187
+
of meaningful characters in the sequence. Hence, everytime that the algorithm produces a
188
188
"padding group", this group is automatically mapped to `=`.
189
189
190
190
As another example, if you give the string "0" as input to a base64 encoder, this string is
@@ -221,7 +221,7 @@ summarized these transformations as "Some bit shifting and additions ..." in the
221
221
will be described in depth later.
222
222
223
223
Besides that, if you look again at @fig-base64-algo2, you will notice that the character `=` was completely
224
-
ignored by the algorithm. Remember, this is just a special character that marks the end of meaninful characters
224
+
ignored by the algorithm. Remember, this is just a special character that marks the end of meaningful characters
225
225
in the base64 sequence. So, every `=` character in a base64 encoded sequence should be ignored by a base64 decoder.
226
226
227
227
@@ -738,7 +738,7 @@ Notice that the output byte is the sequence `ABCDEFGH`, which is the original by
738
738
739
739
{#fig-decoder-bitshift}
740
740
741
-
The @tbl-6bit-decode presents how the three steps described ealier translate into Zig code:
741
+
The @tbl-6bit-decode presents how the three steps described earlier translate into Zig code:
Let’s take for example the word "Hello". In UTF-8, this sequence of characters (H, e, l, l, o)
1074
-
is represented by the sequence of decimal numbers 72, 101, 108, 108, 111. In xecadecimal, this
1074
+
is represented by the sequence of decimal numbers 72, 101, 108, 108, 111. In hexadecimal, this
1075
1075
sequence is `0x48`, `0x65`, `0x6C`, `0x6C`, `0x6F`. So if I take this sequence of hexadecimal values,
1076
1076
and ask Zig to print this sequence of bytes as a sequence of characters (i.e. a string), then,
1077
1077
the text "Hello" will be printed into the terminal:
@@ -1123,7 +1123,7 @@ your trying to access memory that does not belong to you.
1123
1123
1124
1124
To achieve this same kind of safety in C, you have to do a lot of work that kind of seems pointless.
1125
1125
So getting this kind of safety is not automatic and much harder to do in C. For example, if you want
1126
-
to track the length of your string troughout your program in C, then, you first need to loop through
1126
+
to track the length of your string throughout your program in C, then, you first need to loop through
1127
1127
the array of bytes that represents this string, and find the null element (`'\0'`) position to discover
1128
1128
where exactly the array ends, or, in other words, to find how much elements the array of bytes contain.
1129
1129
@@ -1418,7 +1418,7 @@ N of replacements: 1
1418
1418
## Safety in Zig
1419
1419
1420
1420
A general trend in modern low-level programming languages is safety. As our modern world
1421
-
become more interconnected with techology and computers,
1421
+
become more interconnected with technology and computers,
1422
1422
the data produced by all of this technology becomes one of the most important
1423
1423
(and also, one of the most dangerous) assets that we have.
1424
1424
@@ -1466,7 +1466,7 @@ The tools listed below are related to memory safety. That is, they help you to a
1466
1466
memory safety in your Zig code:
1467
1467
1468
1468
-`defer` allows you to keep free operations phisically close to allocations. This helps you to avoid memory leaks, "use after free", and also "double-free" problems. Furthermore, it also keeps free operations logically tied to the end of the current scope, which greatly reduces the mental overhead about object lifetime.
1469
-
-`errdefer` helps you to garantee that your program frees the allocated memory, even if a runtime error occurs.
1469
+
-`errdefer` helps you to guarantee that your program frees the allocated memory, even if a runtime error occurs.
1470
1470
- pointers and objects are non-nullable by default. This helps you to avoid memory problems that might arise from de-referencing null pointers.
1471
1471
- Zig offers some native types of allocators (called "testing allocators") that can detect memory leaks and double-frees. These types of allocators are widely used on unit tests, so they transform your unit tests into a weapon that you can use to detect memory problems in your code.
1472
1472
- arrays and slices in Zig have their lengths embedded in the object itself, which makes the `zig` compiler very effective on detecting "index out-of-range" type of errors, and avoiding buffer overflows.
Copy file name to clipboardexpand all lines: Chapters/04-http-server.qmd
+6-6
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ a separate Zig module. I will name it `config.zig`.
166
166
167
167
In Zig, we can create a web socket using
168
168
the `std.posix.socket()` function, from the Zig Standard Library.
169
-
As I meantioned earlier at @sec-http-how-impl, every socket object that we create
169
+
As I mentioned earlier at @sec-http-how-impl, every socket object that we create
170
170
represents a communication channel, and we need to bind this channel to a specific address.
171
171
An "address" is defined as an IP address, or, more specifically, an IPv4 address^[It can be also an IPv6 address. But normally, we use a IPv4 address for that.].
172
172
Every IPv4 address is composed by two components. The first component is the host,
@@ -178,7 +178,7 @@ The sequence of 4 numbers (i.e. the host) identifies the machine (i.e. the compu
178
178
this socket will live in. Every computer normally have multiple "doors" available inside of him, because
179
179
this allows the computer to receive and work with multiple connections at the same time.
180
180
He simply use a single door for each connection. So the port number, is
181
-
essentially a number that identifies the specific door in the computer that will be resposible
181
+
essentially a number that identifies the specific door in the computer that will be responsible
182
182
for receiving the connection. That is, it identifies the "door" in the computer that the socket will use
183
183
to receive incoming connections.
184
184
@@ -374,8 +374,8 @@ we have provided as input.
374
374
Notice that I'm using the connection object that we created to read
375
375
the message from the client. I first access the `reader` object that lives inside the
376
376
connection object. Then, I call the `read()` method of this `reader` object
377
-
to effectivelly read and save the data sent by the client into the buffer object
378
-
that we created earlier. I'm discarting the return value
377
+
to effectively read and save the data sent by the client into the buffer object
378
+
that we created earlier. I'm discarding the return value
379
379
of the `read()` method, by assigning it to the underscore character (`_`),
380
380
because this return value is not useful for us right now.
381
381
@@ -493,7 +493,7 @@ needs to represent one of the primary colors, you can create an enum
493
493
that represents one of these colors.
494
494
In the example below, we are creating the enum `PrimaryColorRGB`, which
495
495
represents a primary color from the RGB color system. By using this enum,
496
-
I am garanteed that the `acolor` object for example, will contain
496
+
I am guaranteed that the `acolor` object for example, will contain
497
497
one of these three values: `RED`, `GREEN` or `BLUE`.
498
498
499
499
```{zig}
@@ -727,7 +727,7 @@ or a `Method` object as result. Since `GET` is currently the only value in our `
727
727
structure, it means that, the `init()` method will most likely return the value `Method.GET` as result.
728
728
729
729
Also notice that, in the `is_supported()` method, we are using the optional value returned
730
-
by the `get()` method from our `MethodMap` object. The if statement unwrapes the optional value
730
+
by the `get()` method from our `MethodMap` object. The if statement unwraps the optional value
731
731
returned by this method, and returns `true` in case this optional value is a not-null value.
0 commit comments