From 9ff53d423695e56867583f5aa3508468e9fed105 Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Thu, 10 Dec 2020 10:21:29 +0100 Subject: [PATCH] blog: add some missing posts and rename some urls --- ...don-t-you-verify-the-entire-Internet.html} | 0 ... 2011-04-11-C99-promotion-rules-what.html} | 0 ...tml => 2011-06-16-Happy-birthday-IBM.html} | 0 _posts/2011-08-26-Think-of-a-number.html | 12 ++++ ...-sometimes.html => 2011-09-12-better.html} | 0 ...Caml-native-code-shorter-on-Mac-OS-X.html} | 0 _posts/2012-02-09-realloc-is-broken.html | 68 +++++++++++++++++++ ...-of-C-programs-for-FLT_EVAL_METHOD-2.html} | 0 ...-11-Arithmetic-overflows-in-Fluorine.html} | 0 ...pedia-page.html => 2013-07-19-Binade.html} | 0 ...2013-07-24-More-on-FLT_EVAL_METHOD_2.html} | 0 ...=> 2013-10-09-Overflow-float-integer.html} | 0 ...013-10-18-compact-smaller-and-faster.html} | 0 13 files changed, 80 insertions(+) rename _posts/{2011-01-13-Why-don-t-you-verify-the-entire-Internet-.html => 2011-01-13-Why-don-t-you-verify-the-entire-Internet.html} (100%) rename _posts/{2011-04-11-C99-promotion-rules-what-.html => 2011-04-11-C99-promotion-rules-what.html} (100%) rename _posts/{2011-06-16-Happy-birthday-IBM..html => 2011-06-16-Happy-birthday-IBM.html} (100%) create mode 100644 _posts/2011-08-26-Think-of-a-number.html rename _posts/{2011-09-12-Better-is-the-enemy-of-good...-sometimes.html => 2011-09-12-better.html} (100%) rename _posts/{2012-01-07-Making-OCaml-native-code-0.5%-shorter-on-Mac-OS-X.html => 2012-01-07-Making-OCaml-native-code-shorter-on-Mac-OS-X.html} (100%) create mode 100644 _posts/2012-02-09-realloc-is-broken.html rename _posts/{2013-07-06-On-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD--2.html => 2013-07-06-On-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD-2.html} (100%) rename _posts/{2013-07-09-Arithmetic-overflows-in-Fluorine.html => 2013-07-11-Arithmetic-overflows-in-Fluorine.html} (100%) rename _posts/{2013-07-19-The-word-binade-now-has-its-Wikipedia-page.html => 2013-07-19-Binade.html} (100%) rename _posts/{2013-07-15-More-on-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD--2.html => 2013-07-24-More-on-FLT_EVAL_METHOD_2.html} (100%) rename _posts/{2013-10-09-The-overflow-when-converting-from-float-to-integer-is-undefined-behavior.html => 2013-10-09-Overflow-float-integer.html} (100%) rename _posts/{2013-10-11-OCaml-s-option--compact-can-optimize-for-code-size-and-speed.html => 2013-10-18-compact-smaller-and-faster.html} (100%) diff --git a/_posts/2011-01-13-Why-don-t-you-verify-the-entire-Internet-.html b/_posts/2011-01-13-Why-don-t-you-verify-the-entire-Internet.html similarity index 100% rename from _posts/2011-01-13-Why-don-t-you-verify-the-entire-Internet-.html rename to _posts/2011-01-13-Why-don-t-you-verify-the-entire-Internet.html diff --git a/_posts/2011-04-11-C99-promotion-rules-what-.html b/_posts/2011-04-11-C99-promotion-rules-what.html similarity index 100% rename from _posts/2011-04-11-C99-promotion-rules-what-.html rename to _posts/2011-04-11-C99-promotion-rules-what.html diff --git a/_posts/2011-06-16-Happy-birthday-IBM..html b/_posts/2011-06-16-Happy-birthday-IBM.html similarity index 100% rename from _posts/2011-06-16-Happy-birthday-IBM..html rename to _posts/2011-06-16-Happy-birthday-IBM.html diff --git a/_posts/2011-08-26-Think-of-a-number.html b/_posts/2011-08-26-Think-of-a-number.html new file mode 100644 index 00000000..47a83a1e --- /dev/null +++ b/_posts/2011-08-26-Think-of-a-number.html @@ -0,0 +1,12 @@ +--- +layout: post +author: Pascal Cuoq +date: 2011-08-26 09:19 +0200 +categories: +format: xhtml +title: "Think of a number, any number" +summary: +--- +{% raw %} +<p>I like to think the sentence this post borrows as title is one of the most condensed jokes in The Hitch-Hiker's Guide to the Galaxy series, if one takes the sentence to mean "Pick any number using an uniform probability". It may seem that I am over-interpreting, and perhaps I am, but a similar "division by zero" joke is made explicit elsewhere in the series.</p> +{% endraw %} diff --git a/_posts/2011-09-12-Better-is-the-enemy-of-good...-sometimes.html b/_posts/2011-09-12-better.html similarity index 100% rename from _posts/2011-09-12-Better-is-the-enemy-of-good...-sometimes.html rename to _posts/2011-09-12-better.html diff --git a/_posts/2012-01-07-Making-OCaml-native-code-0.5%-shorter-on-Mac-OS-X.html b/_posts/2012-01-07-Making-OCaml-native-code-shorter-on-Mac-OS-X.html similarity index 100% rename from _posts/2012-01-07-Making-OCaml-native-code-0.5%-shorter-on-Mac-OS-X.html rename to _posts/2012-01-07-Making-OCaml-native-code-shorter-on-Mac-OS-X.html diff --git a/_posts/2012-02-09-realloc-is-broken.html b/_posts/2012-02-09-realloc-is-broken.html new file mode 100644 index 00000000..bba72787 --- /dev/null +++ b/_posts/2012-02-09-realloc-is-broken.html @@ -0,0 +1,68 @@ +--- +layout: post +author: Pascal Cuoq +date: 2012-02-09 14:28 +0200 +categories: +format: xhtml +title: "Function realloc() is broken - Not" +summary: +--- +{% raw %} +<p>This post is a sequel of <a href="/2012/01/05/Double-free-no-such-thing.html">this post</a>, in which I argued that it is not possible to double-free a piece of memory, only to pass indeterminate data (specifically, a dangling pointer) to a function (specifically, <code>free()</code>).</p> + + +<h2>Broken</h2> + + +<p>This time I am arguing that the standardized function <code>realloc()</code> is broken. By this I do not mean that a particular implementation is broken. This happens, as I found out searching the web for these very words, just before starting on this post. I mean that the standard definition is broken: it forces the programmer to write eir program either in such a way that it may manipulate indeterminate data (specifically, a dangling pointer) or in such a way that it may leak memory (specifically, the block that couldn't be enlarged).</p> + + +<h2>Naively using <code>realloc()</code>: memory leak</h2> + +<pre>char *p = malloc(...); +... +p = realloc(p, ...); +if (p) +{ + /* good: we got the additional + memory we need. */ + ... +} +else +{ + /* We didn't get the memory. Ah well... + We didn't need it that badly anyway, + let's continue. */ + ... +} +</pre> + + +<p>The problem with this program is that it leaks memory. In the <code>else</code> branch, the block has been preciously kept in memory by <code>realloc()</code>, but the variable <code>p</code> has been overwritten with <code>NULL</code>, the result of the <code>realloc()</code> call, so that there is no way to access it any more or, for that matter, to free it.</p> + + +<h2>The idiomatic solution</h2> + + +<p>The above is a standard pitfall of <code>realloc()</code>, and there is an idiomatic solution:</p> + +<pre>char *p = malloc(...); +... +char *old = p; +p = realloc(p, ...); +if (p) +{ + /* good: we got the additional + memory we need. */ + ... +} +else +{ + /* We didn't get the memory. Ah well... + We didn't need it that badly anyway. + In fact, let's throw away the block right now! */ + free(old); + ... +} +</pre> +{% endraw %} diff --git a/_posts/2013-07-06-On-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD--2.html b/_posts/2013-07-06-On-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD-2.html similarity index 100% rename from _posts/2013-07-06-On-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD--2.html rename to _posts/2013-07-06-On-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD-2.html diff --git a/_posts/2013-07-09-Arithmetic-overflows-in-Fluorine.html b/_posts/2013-07-11-Arithmetic-overflows-in-Fluorine.html similarity index 100% rename from _posts/2013-07-09-Arithmetic-overflows-in-Fluorine.html rename to _posts/2013-07-11-Arithmetic-overflows-in-Fluorine.html diff --git a/_posts/2013-07-19-The-word-binade-now-has-its-Wikipedia-page.html b/_posts/2013-07-19-Binade.html similarity index 100% rename from _posts/2013-07-19-The-word-binade-now-has-its-Wikipedia-page.html rename to _posts/2013-07-19-Binade.html diff --git a/_posts/2013-07-15-More-on-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD--2.html b/_posts/2013-07-24-More-on-FLT_EVAL_METHOD_2.html similarity index 100% rename from _posts/2013-07-15-More-on-the-precise-analysis-of-C-programs-for-FLT_EVAL_METHOD--2.html rename to _posts/2013-07-24-More-on-FLT_EVAL_METHOD_2.html diff --git a/_posts/2013-10-09-The-overflow-when-converting-from-float-to-integer-is-undefined-behavior.html b/_posts/2013-10-09-Overflow-float-integer.html similarity index 100% rename from _posts/2013-10-09-The-overflow-when-converting-from-float-to-integer-is-undefined-behavior.html rename to _posts/2013-10-09-Overflow-float-integer.html diff --git a/_posts/2013-10-11-OCaml-s-option--compact-can-optimize-for-code-size-and-speed.html b/_posts/2013-10-18-compact-smaller-and-faster.html similarity index 100% rename from _posts/2013-10-11-OCaml-s-option--compact-can-optimize-for-code-size-and-speed.html rename to _posts/2013-10-18-compact-smaller-and-faster.html -- GitLab