Skip to content

Commit

Permalink
Merge pull request #201 from tudorsiminic/master
Browse files Browse the repository at this point in the history
Fix typo "earlier rather than later"
  • Loading branch information
angrave authored Dec 9, 2023
2 parents 30d15fb + be6ecac commit 733a91f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions background/background.tex
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ \subsection{Asserts}
Here is a quick example with an assert.
Let's say that we are writing code using memcpy.
We would want to put an assert before that checks whether my two memory regions overlap.
If they do overlap, memcpy runs into undefined behavior, so we want to catch that problem than later.
If they do overlap, memcpy runs into undefined behavior, so we want to discover that problem sooner rather than later.

\begin{lstlisting}[language=C]
assert(!(src < dest+n && dest < src+n)); //Checks overlap
assert( src+n < dest || src >= dest + n); // source should finish before the destination or the source starts after the end of destination
memcpy(dest, src, n);
\end{lstlisting}

Expand Down

0 comments on commit 733a91f

Please sign in to comment.