<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>happyholiday</author_name>
  <author_url>https://blog.hatena.ne.jp/happyholiday/</author_url>
  <blog_title>六帖のかたすみ</blog_title>
  <blog_url>https://rokujo.hatenadiary.com/</blog_url>
  <categories>
    <anon>プログラミング</anon>
  </categories>
  <description>知っている人には当たり前のことかもしれないけれど、デバッグで一度躓いたので。 メモリ容量が足りないからreallocをして容量を拡張しようとすると、なんとポインタの位置が変わってしまう。したがって、 LPSTR p; /*何か読み込み処理*/ if(/*バッファ不足*/) { p = realloc(p, MAX_SIZE); }のようなことをしてはいけない。pの中身を他の変数で参照していたら、reallocした瞬間に他の変数が参照している場所が不正な位置になって、下手するとメモリ破壊、アクセスバイオレーションエラーになる。 また、reallocに失敗すればNULLが返ってくるから、pが参照し…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frokujo.hatenadiary.com%2Fentry%2F20140409%2F1397011035&quot; title=&quot;C++ reallocはアドレスが変わる - 六帖のかたすみ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-04-09 11:37:15</published>
  <title>C++ reallocはアドレスが変わる</title>
  <type>rich</type>
  <url>https://rokujo.hatenadiary.com/entry/20140409/1397011035</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
