<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=Talk%3ASE250%3AHTTB%3AWIP%3AArray-based_Lists%3AScreencasts%3Asdal039</id>
	<title>Talk:SE250:HTTB:WIP:Array-based Lists:Screencasts:sdal039 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=Talk%3ASE250%3AHTTB%3AWIP%3AArray-based_Lists%3AScreencasts%3Asdal039"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=Talk:SE250:HTTB:WIP:Array-based_Lists:Screencasts:sdal039&amp;action=history"/>
	<updated>2026-04-16T21:33:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=Talk:SE250:HTTB:WIP:Array-based_Lists:Screencasts:sdal039&amp;diff=13754&amp;oldid=prev</id>
		<title>Mark: 1 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=Talk:SE250:HTTB:WIP:Array-based_Lists:Screencasts:sdal039&amp;diff=13754&amp;oldid=prev"/>
		<updated>2008-11-03T10:43:35Z</updated>

		<summary type="html">&lt;p&gt;1 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Nice concise screencast.  Your diagrams explain things correctly, but your code is wrong and the observation about the runtime is irrelevant.  Realloc is not unreliable.  You are malloc&amp;#039;ing an unreasonably large block of memory, then calling realloc on a very small amount (try printing out sizeof(arr) &amp;amp;mdash; I think you&amp;#039;ll find it is 4 bytes only).&lt;br /&gt;
&lt;br /&gt;
The code we want to compare is:&lt;br /&gt;
&lt;br /&gt;
      element_t* newarr = malloc( required_capacity * sizeof( element_t ) );&lt;br /&gt;
      memmove( newarr, alist-&amp;gt;arr, alist-&amp;gt;length * sizeof(element_t) );&lt;br /&gt;
      free( alist-&amp;gt;arr );&lt;br /&gt;
&lt;br /&gt;
compared with&lt;br /&gt;
&lt;br /&gt;
      alist-&amp;gt;arr = realloc( alist-&amp;gt;arr, required_capacity * sizeof(element_t) );&lt;br /&gt;
&lt;br /&gt;
The former always allocates a new memory block, whereas the latter only does so if there is another allocation preventing expansion of the current memory block.  In a &amp;quot;real&amp;quot; program, expansion is almost always blocked.  In our benchmark experiment, it never is.&lt;br /&gt;
&lt;br /&gt;
:[[User:Jham005|Jham005]] 16:30, 22 April 2008 (NZST)&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>