<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div><font face="Calibri, sans-serif"> m3tohtml/src/Main.m3: </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> sources is global </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> PROCEDURE Add() = </font></div><div><font face="Calibri, sans-serif"> BEGIN </font></div><div><font face="Calibri, sans-serif"> sources := NEW (Source, next := sources, </font></div><div><font face="Calibri, sans-serif"> from := Pathname.Join(pkgpath, file, NIL), </font></div><div><font face="Calibri, sans-serif"> to := Pathname.Join(pkg, FixDerived (file), NIL), </font></div><div><font face="Calibri, sans-serif"> kind := kind); </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> It APPEARS this compiles to like: </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> temp = RTHooks__AllocateTracedRef(...); </font></div><div><font face="Calibri, sans-serif"> sources = temp </font></div><div><font face="Calibri, sans-serif"> if temp == NULL </font></div><div><font face="Calibri, sans-serif"> raise exception </font></div><div><font face="Calibri, sans-serif"> sources->from = ... </font></div><div><font face="Calibri, sans-serif"> sources->to = ... </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> To me this seems a bit suspicious. </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> First, the null check should be against the temp. </font></div><div><font face="Calibri, sans-serif"> Sources should not be assigned and then checked. </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> Second, probably, the fields of sources should be filled in before </font></div><div><font face="Calibri, sans-serif"> the global. </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> So, it should be more like: </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> </font></div><div><font face="Calibri, sans-serif"> temp = RTHooks__AllocateTracedRef(); </font></div><div><font face="Calibri, sans-serif"> if temp == NULL </font></div><div><font face="Calibri, sans-serif"> raise exception </font></div><div><font face="Calibri, sans-serif"> temp->from = ... </font></div><div><font face="Calibri, sans-serif"> temp->to = ... </font></div><div><font face="Calibri, sans-serif"> sources = temp </font></div><div><font face="Calibri, sans-serif"> ... </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Just as efficient, but "safer".</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Now, I realize, without a lock or barrier, the compiler is free to reorder like this.</font></div><div><font face="Calibri, sans-serif">Maybe ideally temp would be gone but the original order used?</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">C++ would implement it more like how I showed.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Thoughts?</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> - Jay</font></div><br><br> </div></body>
</html>