<div dir="auto">I remember that it wasn't unusual on Windows to define malloc, calloc, strdup, and free macros to redirect those calls to custom wrappers. That would eliminate the need to have non-standard names like MALLOC.<div dir="auto"><br></div><div dir="auto">There is also the pipe_reference debug code. Is anybody using that?<br><div dir="auto"><br></div><div dir="auto">Marek</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun., Dec. 26, 2021, 05:37 Jose Fonseca, <<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I believe that as long as the CALLOC_STRUCT continue to get paired with right FREE call (or equivalent if these get renamed) either way should work for us.  Whatever option proposed gets followed, there's a risk these can get out of balanced, but the risk seems
 comparable.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
For context, IIRC, the main reason these macros remain useful for VMware is the sad state of memory debugging tools on Windows.  AFAICT, best hope of one day deprecating this would be use AddressSanitizer, which is supported on MSVC [1], but unfortunately not
 yet on MinGW w/ GCC [2], and we rely upon a lot for day-to-day development, using Linux cross-compilation.  Using MinGW w/ Clang cross compiler seems be a way to overcome this difficulty, but that too was still in somewhat experimental state when I last tried
 it.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Jose</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
[1] <a href="https://devblogs.microsoft.com/cppblog/asan-for-windows-x64-and-debug-build-support/" target="_blank" rel="noreferrer">https://devblogs.microsoft.com/cppblog/asan-for-windows-x64-and-debug-build-support/</a></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
[2] <a href="https://stackoverflow.com/questions/67619314/cannot-use-fsanitize-address-in-mingw-compiler" target="_blank" rel="noreferrer">https://stackoverflow.com/questions/67619314/cannot-use-fsanitize-address-in-mingw-compiler</a></div>
<hr style="display:inline-block;width:98%">
<div id="m_8070065236719378998divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Dave Airlie <<a href="mailto:airlied@gmail.com" target="_blank" rel="noreferrer">airlied@gmail.com</a>><br>
<b>Sent:</b> Wednesday, December 22, 2021 22:35<br>
<b>To:</b> mesa-dev <<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank" rel="noreferrer">mesa-dev@lists.freedesktop.org</a>>; Jose Fonseca <<a href="mailto:jfonseca@vmware.com" target="_blank" rel="noreferrer">jfonseca@vmware.com</a>>; Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank" rel="noreferrer">brianp@vmware.com</a>><br>
<b>Subject:</b> revenge of CALLOC_STRUCT</font>
<div> </div>
</div>
<div><font size="2"><span style="font-size:11pt">
<div>Hey,<br>
<br>
Happy holidays, and as though to consider over the break,<br>
<br>
We have the vmware used MALLOC/FREE/CALLOC/CALLOC_STRUCT wrappers used<br>
throughout gallium.<br>
<br>
We have ST_CALLOC_STRUCT in use in the mesa state tracker, not used in gallium.<br>
<br>
Merging the state tracker into mesa proper, and even prior to this a<br>
few CALLOC_STRUCT have started to leak into src/mesa/*.<br>
<br>
Now I don't think we want that, but CALLOC_STRUCT is a genuinely<br>
useful macro on it's own,<br>
I'm considering just defined a calloc_struct instead for the<br>
non-gallium use that goes with malloc/calloc/free.<br>
<br>
Any opinions, or should mesa just get u_memory.h support for Xmas?<br>
<br>
Dave.<br>
</div>
</span></font></div>
</div>

</blockquote></div>