X Window研究笔记(21)

<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>
X Window研究笔记(21)

转载时请注明出处和作者联系方式
作者联系方式:李先静 <xianjimli at hotmail dot com><br><br><font size="4" style="font-weight: bold;">21.X Window 字符串与Atom</font><br><br>Atom是X Window中的一大特色,不把它弄清楚,可能会对阅读其它代码形成障碍。X Window把常用的字串用一个hash表来管理,并给这些字符串赋与一个ID,客户端通过ID引用字符串,避免在客户端和服务器端之间来回传递这些它们,这样可以大大提高传输效率。另外Atom是一个整数,对整数的比较也比对字符串的比较有更快的速度。管理Atom的主要函数有:<br><br><div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"><div><font><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""><span style="color: rgb(0, 0, 0);">Atom<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt="">MakeAtom(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">,len,makeit)<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""></span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt="">unsignedlen;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt="">Boolmakeit;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""></span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt="">NameForAtom(atom)<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt="">Atomatom;<br><img align="top" onclick="this.style.display='none'; document.getElementById('_130_293_Open_Text').style.display='none'; document.getElementById('_130_293_Closed_Image').style.display='inline'; document.getElementById('_130_293_Closed_Text').style.display='inline';" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" id="_130_293_Open_Image" alt=""><img align="top" onclick="this.style.display='none'; document.getElementById('_130_293_Closed_Text').style.display='none'; document.getElementById('_130_293_Open_Image').style.display='inline'; document.getElementById('_130_293_Open_Text').style.display='inline';" style="display: none;" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" id="_130_293_Closed_Image" alt=""></span><span style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255); display: none;" id="_130_293_Closed_Text">...</span><span id="_130_293_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt="">NodePtrnode;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt=""></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(atom</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">lastAtom)</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt=""></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">((node</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">nodeTable[atom])</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">(NodePtr)NULL)</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt=""></span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">node</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" alt="">}</span></span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt="">FreeAtom(NodePtrpatom)<br><img align="top" onclick="this.style.display='none'; document.getElementById('_338_537_Open_Text').style.display='none'; document.getElementById('_338_537_Closed_Image').style.display='inline'; document.getElementById('_338_537_Closed_Text').style.display='inline';" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" id="_338_537_Open_Image" alt=""><img align="top" onclick="this.style.display='none'; document.getElementById('_338_537_Closed_Text').style.display='none'; document.getElementById('_338_537_Open_Image').style.display='inline'; document.getElementById('_338_537_Open_Text').style.display='inline';" style="display: none;" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" id="_338_537_Closed_Image" alt=""></span><span style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255); display: none;" id="_338_537_Closed_Text">...</span><span id="_338_537_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt=""></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(patom</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">left)<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt="">FreeAtom(patom</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">left);<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt=""></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(patom</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">right)<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt="">FreeAtom(patom</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">right);<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt=""></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(patom</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">XA_LAST_PREDEFINED)<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt="">xfree(patom</span><span style="color: rgb(0, 0, 0);">-&gt;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">);<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" alt="">xfree(patom);<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" alt="">}</span></span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" alt=""></span></font></div></div> <br>(待续)<br></xianjimli>


你可能感兴趣的:(window)