<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1999465060024415285</id><updated>2012-01-19T22:04:29.912+04:00</updated><category term='WINGs/handlers.c'/><category term='Memory'/><category term='WINGs/array.c'/><category term='WINGs/list.c'/><category term='WINGs/notification.c'/><category term='WINGs/memory.c'/><category term='General'/><category term='WINGs/string.c'/><category term='WINGs/objects.c'/><category term='WINGs/Tests'/><title type='text'>Rewriting WindowMaker...</title><subtitle type='html'>&lt;p&gt;&lt;i&gt;&amp;laquo;I understand that you are in a quest to purge all evil from the code ...&amp;raquo;&lt;/i&gt;&lt;br&gt;&lt;small&gt;Alfredo Kojima&lt;/small&gt;&lt;/p&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-7065749194003596586</id><published>2007-12-10T08:00:00.000+03:00</published><updated>2007-12-10T07:58:17.430+03:00</updated><title type='text'>Few Words For the Trees</title><content type='html'>&lt;div style="text-align: justify;"&gt;Reimplementing red-black tree data structure, which exist in WINGs, but heavily underused, I've found one funny optimization. Everyone is starting with classical rotate_left and rotate_right functions, and they're updating root node on every rotation. That causes more checks and assignments than required in some cases. Solution is simple as always: tree rotation functions can be simplified by factoring out code for setting root node.&lt;br /&gt;&lt;br /&gt;I must admit that this particular code is pretty good in WINGs. There's only a little space for improvement. And it makes me wonder why those beautiful trees weren't used for example in implementing hash tables. Hash tables in WINGs are simple arrays of pairs, and it's really possible to speed them up a lot.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;I'm looking at &lt;a href="http://savannah.nongnu.org/"&gt;savannah&lt;/a&gt;. It's most likely, that I host nexmaker project there.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-7065749194003596586?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/7065749194003596586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=7065749194003596586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/7065749194003596586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/7065749194003596586'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/12/few-words-for-trees.html' title='Few Words For the Trees'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-6207613972618794559</id><published>2007-11-30T17:00:00.000+03:00</published><updated>2007-11-30T16:24:32.740+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><title type='text'>New Memory Layout</title><content type='html'>&lt;div style="text-align: justify;"&gt;I have «invented» new memory layout for objects. Now creating new objects as well as wrapping simple data in object is very simple.  The solution is to keep internal fields at negative offsets. The &lt;span style="font-family: verdana;"&gt;nm_object&lt;/span&gt; function returns pointer inside allocated block, and &lt;span style="font-family: verdana;"&gt;nm_release&lt;/span&gt; is able to find &lt;span style="font-family: verdana;"&gt;free&lt;/span&gt; and &lt;span style="font-family: verdana;"&gt;destroy&lt;/span&gt; methods out of this pointer. Additionally, deallocation of memory and destruction of object is now two different configurable operations. This allows me to create objects on stack or using ob-stacks or any other memory manager.&lt;br /&gt;&lt;br /&gt;Working with objects is really simple now. I'm having fun with hacking nm again. :)&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-6207613972618794559?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/6207613972618794559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=6207613972618794559' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/6207613972618794559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/6207613972618794559'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/11/new-memory-layout.html' title='New Memory Layout'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-9206592196933102000</id><published>2007-11-23T15:00:00.000+03:00</published><updated>2007-11-23T15:03:58.275+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Wrong Way</title><content type='html'>&lt;div style="text-align: justify;"&gt;Seems like I stepped on a wrong path. Things are getting too complicated. I'm not ready to support full objects hierarchy in plain C. I don't want a lot of automatic actions. The code should be much simpler.&lt;br /&gt;&lt;br /&gt;Some things learned from what have been done are useful. I'll keep the experience and continue hacking source in some other way. It's time to think. :)&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-9206592196933102000?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/9206592196933102000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=9206592196933102000' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/9206592196933102000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/9206592196933102000'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/11/wrong-way.html' title='Wrong Way'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-1303064011617345050</id><published>2007-11-06T09:00:00.000+03:00</published><updated>2007-11-06T08:52:16.096+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>New API Structure</title><content type='html'>&lt;div style="text-align: justify;"&gt;As I already noted, I have played a little with valgrind and kcachegrind, and measured some new code against ideal, hand-written code. The first thing I noted is amount of time spent in &lt;span style="font-family: verdana;"&gt;malloc &lt;/span&gt;and &lt;span style="font-family: verdana;"&gt;free&lt;/span&gt; functions. Another thing is that time spent in single wrapper function became significiant when that function is called about millions of times. Let's look closer at &lt;span style="font-family: verdana;"&gt;WMCreateObject &lt;/span&gt;function. It is simple wrapper over malloc with few checks. In the nearest future this function will be called everywhere. Why not make it inline?&lt;br /&gt;&lt;br /&gt;Another issue, that eats time on many calls is checks for null-pointers. I don't like the idea of terminating application once I got out of memory. It's application's job to decide what to do. Construction functions return &lt;span style="font-family: verdana;"&gt;NULL&lt;/span&gt; if memory allocation fails. If it doesn't fail they're filling allocated memory with some data.  And those checks are really taking time. Generally I don't need more than one check for single object construction call.&lt;br /&gt;&lt;br /&gt;The solution I came is to divide API. Internal API will be set on small, mostly inline functions, mostly without any checks. This doesn't mean it would call malloc and than unconditionally write something in returned pointer. Memory allocation and filling object with data is just different functions. With this structure  I will be able to allocate memory, check for &lt;span style="font-family: verdana;"&gt;NULL&lt;/span&gt;, and call multiple filling functions without penalty for additional checks.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-1303064011617345050?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/1303064011617345050/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=1303064011617345050' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/1303064011617345050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/1303064011617345050'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/11/new-api-structure.html' title='New API Structure'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-4019133699325146361</id><published>2007-10-23T11:00:00.000+04:00</published><updated>2007-10-23T11:49:55.922+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Naming Conventions</title><content type='html'>&lt;div style="text-align: justify;"&gt;I'm changing the project name. The name WindowMaker will be held by original project. It's possible that original development team will wake up at some day and produce something. I doubt that they will, but it's possible anyway. Since I'm practically forking original project, it's good idea to change the name. NextMaker seems like a good name for my project. I thought it out in times of first attempt to fork, and I think, I'll keep it now.&lt;br /&gt;&lt;br /&gt;Now, to the style. I don't like pascalish names used everywhere in WindowMaker. I'll make them all lowercase and with underscore as word separator. The shorter name is better the longer one. Prefix change reflects change in project name. Now all function names will start with «nm» instead of «WM». Prefixes and suffixes of names will have some meanings: «nm_» stands for ordinary exported functions, «nmi_» is for internal functions, which is usually inlined, «nmt_» is for type-tags in object system and so on. For example WMReleaseObject function will become nm_release after change, and WMString will be nmt_string.&lt;br /&gt;&lt;br /&gt;I won't do that all at once. Changes will be made only in parts of code I'm touching. There's also some plans on changing file layout and structure of API, but those are things I'll think about a little bit later.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-4019133699325146361?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/4019133699325146361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=4019133699325146361' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/4019133699325146361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/4019133699325146361'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/10/naming-conventions.html' title='Naming Conventions'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-4435530636635286860</id><published>2007-10-16T11:00:00.000+04:00</published><updated>2007-10-16T11:01:32.212+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/list.c'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/notification.c'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/handlers.c'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/array.c'/><title type='text'>WMArray vs. WMList</title><content type='html'>&lt;div style="text-align: justify;"&gt;Yesterday I have analized sources of WINGs and WindowMaker a little. Now I'm certain that &lt;span style="font-family:verdana;"&gt;WMArrays&lt;/span&gt; are mostly misused.  Little research showed that the most used pattern of accessing data in arrays is plain iteration form beginning to end. There are only four exceptions (out of approximately 23 use cases), where random access to data is used: &lt;span style="font-family:verdana;"&gt;WMList&lt;/span&gt;, &lt;span style="font-family:verdana;"&gt;WMPopupButton&lt;/span&gt;, &lt;span style="font-family:verdana;"&gt;WMSplitView&lt;/span&gt;, and switch panel. And I don't think that all of those can't be converted to using linked lists and be more efficient. Moreover, linked lists are actually used in many places in WINGs. For example, event handlers are organized in lists, notification observers are also organized in lists.&lt;br /&gt;&lt;br /&gt;I'm not talking here about blind replacing of all arrays with linked lists, it would be stupid. But if I feel that linked list is more appropriate structure for particular task, I'll use it. If I see, that some linked list is implemented ad hoc, I'll replace it with &lt;span style="font-family:verdana;"&gt;WMLList&lt;/span&gt; data structure. There's possibility that after removal of  &lt;span style="font-family:verdana;"&gt;WMPropList&lt;/span&gt;s, &lt;span style="font-family:verdana;"&gt;WMLList&lt;/span&gt;s will take place of proplist arrays.&lt;br /&gt;&lt;br /&gt;Since the name &lt;span style="font-family:verdana;"&gt;WMList&lt;/span&gt; is already taken by list widget, I will use the name &lt;span style="font-family:verdana;"&gt;WMLList&lt;/span&gt; for data structure. I will probably change all names later anyway. Now I'm implementing &lt;span style="font-family:verdana;"&gt;WMLList&lt;/span&gt; object as double-linked list. If there will be never the need to iterate those lists in reverse direction, I'll remove second pointer, but currently I think this small memory overhead will pay off shortly.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-4435530636635286860?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/4435530636635286860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=4435530636635286860' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/4435530636635286860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/4435530636635286860'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/10/wmarray-vs-wmlist.html' title='WMArray vs. WMList'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-8261429147968512622</id><published>2007-10-12T11:00:00.000+04:00</published><updated>2007-10-12T11:10:43.608+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/string.c'/><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><title type='text'>Strings Handling</title><content type='html'>&lt;div style="text-align: justify;"&gt;The idea is to keep length of string together with characters, just like in old &lt;span style="font-family:verdana;"&gt;WMData&lt;/span&gt; structure. In first attempt I allocated buffer with second call to &lt;span style="font-family:verdana;"&gt;malloc&lt;/span&gt; and stored only pointer to character buffer in the object. Then after playing a little with profiler I've changed code to use flexible array for a buffer. That also eliminated the need for &lt;span style="font-family:verdana;"&gt;WMString&lt;/span&gt;-specific destructor. Now I have a function &lt;span style="font-family:verdana;"&gt;WMCreateString&lt;/span&gt; which does basically the same as &lt;span style="font-family:verdana;"&gt;wstrdup&lt;/span&gt; (and a little more, because it at least keeps length of the string), but performs about 10% faster.&lt;br /&gt;&lt;br /&gt;The other thing I will certainly need is some function to concatenate mupltiple strings. This function will replace &lt;span style="font-family:verdana;"&gt;wstrconcat&lt;/span&gt;, &lt;span style="font-family:verdana;"&gt;wstrappend&lt;/span&gt;, and also &lt;span style="font-family:verdana;"&gt;sprintf&lt;/span&gt; in many places. What I don't like about existing functions is calls to &lt;span style="font-family:verdana;"&gt;realloc&lt;/span&gt;. It is much better to collect strings to be concatenated in some kind of container like array or list, calculate length of the resulting string, call &lt;span style="font-family:verdana;"&gt;malloc&lt;/span&gt; and copy all data int new string. It would be also good in some situations to have function with variable argument list, that concatenates all its arguments.&lt;br /&gt;&lt;br /&gt;I have even more ideas for handling strings. For example it may save a lot of CPU time if there will be string objects that doesn't copy literal strings when it's not absolutely needed, and keeps only pointer to it. Or it could be wise to create objects to represent substrings. They will keep reference to original string, offset, and length. Now I have ideas for at least four differend kind of strings. I think it is a good time to start experimenting with subobjects which will have more methods than just &lt;span style="font-family:verdana;"&gt;destroy&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-8261429147968512622?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/8261429147968512622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=8261429147968512622' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/8261429147968512622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/8261429147968512622'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/10/strings-handling.html' title='Strings Handling'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-2232708927688329355</id><published>2007-10-09T10:00:00.001+04:00</published><updated>2007-10-09T10:56:52.528+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/objects.c'/><title type='text'>Object System Issues</title><content type='html'>&lt;div style="text-align: justify;"&gt;I have actually started hacking new object system for WINGs.  The first thing I have noticed is that I don't want type tags to be dynamically allocated. It's very unclear when to destroy and free memory of such dynamic objects. Pointers to statically allocated objects should work as well.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;It was excellent decision to start writing tests. The first thing I stepped on was dynamic type tags, and the second was lack of inheritance in C. &lt;span style="font-family:verdana;"&gt;WMRetainObject&lt;/span&gt; and &lt;span style="font-family:verdana;"&gt;WMReleaseObject&lt;/span&gt; functions now accept pointer to void type as argument as most generic type of pointers. There is no way to specify that function accepts pointers to objects only derived from &lt;span style="font-family:verdana;"&gt;WMObject&lt;/span&gt; structure. Now it is at least possible to use these functions without explicit type casts or some other ways to converting types.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I thought about where to start actually replacing current WINGs' objects with newer ones.  It won't be PropLists. PropLists will be replaced almost at the end, just before I'll start hacking widgets. It won't be any of container types. All of them will be replaced little later. First two candidates for replacement is &lt;span style="font-family:verdana;"&gt;WMData&lt;/span&gt; and... strings. I choose to start with strings.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-2232708927688329355?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/2232708927688329355/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=2232708927688329355' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/2232708927688329355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/2232708927688329355'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/10/object-system-issues.html' title='Object System Issues'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-5251376739660416609</id><published>2007-10-05T10:00:00.001+04:00</published><updated>2007-10-05T10:53:45.511+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/Tests'/><title type='text'>Testing</title><content type='html'>&lt;div style="text-align: justify;"&gt;Nobody will argue that code needs testing. Testing can be performed in numerous ways. Sometimes testing is not enforced by project conventions (which happens at work mostly, because no-one is willing to spend time to create something that don't provide any cool features). In those projects I usually create bunch of files named a.c, b.c and so on in a root directory of a project. These are «tests». I compile and run them by hand. I never commit those files, and often forget what are they for. I'm always afraid to delete them by some mistake.&lt;br /&gt;&lt;br /&gt;In my home projects I have a freedom to do whatever I want, including writing «useless» code solely for testing purposes. And I feel good. Whenever I want to know if my recent changes break something I can type &lt;span style="font-family:verdana;"&gt;«make sure»&lt;/span&gt; and check that everything is ok (or not ok :) ). I would like to do such things with WINGs too, but no-one before me cared to write any tests for WINGs. Few small programs in WINGs/Tests directory can't be counted as real tests. They're just like my ?.c files in projects at work with one small exception: they are commited in cvs.&lt;br /&gt;&lt;br /&gt;I use &lt;a href="http://www.gethos.net/opensource/cunit"&gt;cunit&lt;/a&gt; package to test the code written in C and &lt;a href="http://valgrind.org/"&gt;valgrind&lt;/a&gt; to detect memory leaks. Usually, I just run cunit program under valgrind. I'm starting writing tests for parts of WINGs I touched. Tests won't be compiled by default. I don't want to force everybody to install cunit at their systems. To start testing go to WINGs/Tests directory and type &lt;span style="font-family:verdana;"&gt;«&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;make sure&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;»&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-5251376739660416609?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/5251376739660416609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=5251376739660416609' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/5251376739660416609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/5251376739660416609'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/10/testing.html' title='Testing'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-5828974756555957136</id><published>2007-10-02T10:00:00.000+04:00</published><updated>2007-10-02T10:28:23.399+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/memory.c'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/objects.c'/><title type='text'>Reference Counting and Objects</title><content type='html'>&lt;div style="text-align: justify;"&gt;While I was looking at WINGs/memory.c eliminating malloc wrappers, I've found two functions that drew my attention. It was &lt;span style="font-family:verdana;"&gt;wretain&lt;/span&gt; and &lt;span style="font-family:verdana;"&gt;wrelease&lt;/span&gt;. If I'm not mistaken, the original idea was to eliminate all handcrafted reference counting code into one place. This is definitely the Good Thing™. But current implementation just sucks. Using hashtables for storing counters with pointers as a keys is definitely not my way of thinking. And those functions are used only in small number of objects in library, with handcrafted reference counting functions for all other objects.&lt;br /&gt;&lt;br /&gt;Let's go into that problem little deeper. WINGs library does have objects. In fact there's at least three kind of objects, with different ways to distinguish types:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; «raw» data structures like WMArray, WMBag etc with no way to determine type;&lt;/li&gt;&lt;li&gt;PropList-wrappers over raw structures with closed set of type tags;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;widgets with open set of type tags, but with rudimentary support for creating new type tags.&lt;/li&gt;&lt;/ul&gt;Some of these objects use generalized reference counting and some not. That makes total of six potential object systems with five of them actually implemented. I don't understand why there should be more than one object representing one thing, moreover if those objects have different APIs. I don't understand why there should be more than one object system in single library.&lt;br /&gt;&lt;br /&gt;I think I'll replace this object's zoo with something better. I came up with the following idea. Two common fields for all object are almost obvious. These are some kind of a type tag, and a reference counter for that object. The best kind of type tag I can think of is a pointer to a structure with pointers to methods as fields. I'll start it with the single destroy field, which if present will handle additional operations needed to destroy an object. This solution may add just a little overhead to some  «raw» objects, and no overhead to all others. They're already have something like counter field, type tags or destructor field. This overhead should pay off when I start replacement of PropLists with new objects.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-5828974756555957136?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/5828974756555957136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=5828974756555957136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/5828974756555957136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/5828974756555957136'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/10/reference-counting-and-objects.html' title='Reference Counting and Objects'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-2830447225393874936</id><published>2007-09-28T10:00:00.000+04:00</published><updated>2007-09-28T13:44:00.237+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='WINGs/memory.c'/><title type='text'>MALLOC Wrappers Is Bad</title><content type='html'>&lt;div style="text-align: justify;"&gt;I have found my old messages to wm-core@w.o mailing list. I have to admit that I still agree with most things I've said then. I still think that no library function should print something on the screen unless this is the main goal of the function. As the only exception to this rule I can accept some debugging output&lt;span style="font-style: italic;"&gt; I can disable&lt;/span&gt;. I remember how much trouble was working with &lt;a href="http://xmlsoft.org/"&gt;libxml2&lt;/a&gt; which prints various warnings about malformed xml being parsed with no way to disable this. Exactly the same things I think about termination of applications within the library function. I prefer that these decisions should be left for application.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I thought about using &lt;a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/"&gt;Boehm garbage collector&lt;/a&gt; library. There's even some experimental code in &lt;a href="http://windowmaker.info/"&gt;WindowMaker&lt;/a&gt; to use it. It looks like a very appealing idea for a lisper like me. But garbage collectors are generally incompatible with tools like valgrind. And I want to use such tools, at least until I clean up the code. Also, using some garbage collecting library can possibly happen to be incompatible with some future changes like embedding extension language such as guile, which uses own garbage collector.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I decided to eliminate &lt;span style="font-family:verdana;"&gt;wmalloc,&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;wmalloc0&lt;/span&gt;, &lt;span style="font-family:verdana;"&gt;wrealloc&lt;/span&gt;, and &lt;span style="font-family:verdana;"&gt;wfree&lt;/span&gt; functions. Checking return value everywhere &lt;span style="font-family:verdana;"&gt;malloc&lt;/span&gt; is used and reacting gracefully to that condition requires huge amount of work. It will take some time, and probably will be the cause of many other changes. I'll do it in a number of small steps.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-2830447225393874936?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/2830447225393874936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=2830447225393874936' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/2830447225393874936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/2830447225393874936'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/09/malloc-wrappers-is-bad.html' title='MALLOC Wrappers Is Bad'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1999465060024415285.post-5647177149506830148</id><published>2007-09-25T10:00:00.000+04:00</published><updated>2007-09-25T10:25:36.610+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Quest Description</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;a href="http://windowmaker.info/"&gt;WindowMaker&lt;/a&gt; is dead. Admit it. Website is half-alive, cvs is down, mailing lists are down, last release was more than two years ago. About three years ago, in previous stale period I have tried to start hacking it. The results were creation of new development team, creation of WM2 branch, and new release of main branch. Now the project staled again for a long time already.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I'm starting hacking it again. This time I work alone, privately, without any team. I am doing this for my own amusement and I fell free to change anything I want, even if what I change is a minor, unimportant, or low-priority improvement. I have source of the last release, and the cvs snapshot I was able to catch before servers went down. I don't care for «official releases», but at some point I'll make my git repository publicly available. I don't accept any patches. I don't want your code, please don't spoil my hacking fun. :) But I would be thankful for ideas and code reviews.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This blog is attempt to document the way I was thinking while changing code. Everyone can check &lt;span style="font-style: italic;"&gt;what&lt;/span&gt; was changed, and &lt;span style="font-style: italic;"&gt;how&lt;/span&gt; it was changed using version control tool. With some discipline from committer, it's even possible to see &lt;span style="font-style: italic;"&gt;why&lt;/span&gt; something was changed. I thought that writing a blog can be a good way for describing decisions not directly affecting the code. And it can show what I was thinking about when decided to make some change.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Tags are filenames in repository. May be I will use some additional tags when appropriate. When my git repositary go public, I'll write commit ids to related postings.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1999465060024415285-5647177149506830148?l=nextmaker.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nextmaker.blogspot.com/feeds/5647177149506830148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1999465060024415285&amp;postID=5647177149506830148' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/5647177149506830148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1999465060024415285/posts/default/5647177149506830148'/><link rel='alternate' type='text/html' href='http://nextmaker.blogspot.com/2007/09/quest-description.html' title='Quest Description'/><author><name>Voins</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
