<div dir="ltr"><div><div><div>Wow, <br></div>I wonder how you got the idea to do this check!<br></div><div>ending with 19 bytes may have very bad consequences for perf if it is not a 8 byte multiple.<br></div><div>Nice find.<br></div><div><br></div>Cheers,<br></div>Rémi-C<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-08 11:56 GMT+02:00 Sandro Santilli <span dir="ltr"><<a href="mailto:strk@keybit.net" target="_blank">strk@keybit.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Checking the size of PcPoint values (with pc_memsize and pg_column_size)<br>
I found that we're using 11 bytes for the header when instead only 8 are<br>
required:<br>
<br>
 typedef struct<br>
 {<br>
   uint32_t size; //   4<br>
   uint32_t pcid; //  +4 = 8<br>
   uint8_t data[1];<br>
 }<br>
 SERIALIZED_POINT;<br>
<br>
This is because the code uses sizeof(SERIALIZED_POINT) - 1 to determine<br>
the required size, but sizeof(SERIALIZED_POINT) is 12 on my machine,<br>
rather than 9 as expected by the code.<br>
<br>
In turn, 12 means that the structure is padded to the closest 4bytes<br>
boundary (4+4+4 rather than 4+4+1).<br>
<br>
As we're going to add the actual size of the dimensions, that padding<br>
would not necessarely be needed. For example, a PcPoint with 3 4bytes<br>
dimensions would be perfectly aligned with just 16 bytes. Instead<br>
it uses 8+11=19 bytes.<br>
<br>
Similar assumption (no padding) is done for the PcPatch case, whose<br>
struct also ends with an uint8_t.<br>
<br>
I hadn't checked if such 3 bytes padding sums up for each point in<br>
a patch but it sounds like something worth inspecting.<br>
<br>
--strk;<br>
<br>
  ()   Free GIS & Flash consultant/developer<br>
  /\   <a href="http://strk.keybit.net/services.html" target="_blank">http://strk.keybit.net/services.html</a><br>
_______________________________________________<br>
pgpointcloud mailing list<br>
<a href="mailto:pgpointcloud@lists.osgeo.org">pgpointcloud@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/pgpointcloud" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/pgpointcloud</a><br>
</blockquote></div><br></div>