I'm glad that you liked my post!
I actually used the Perl hash algorithm in a C project once. So I got pretty far into how Perl did it.
I wrote a .h file, memtracker.h for a local college. Students just included this .h file in
their C or C++ program and magic happened. Without any source mods or link dependencies, this
thing tracked C or C++ memory allocations and deallocations and when the user program exited, it showed whether
there were any memory leaks and a table showing how all of this played out. It would say things like
"on line X, that memory allocation has no corresponding deallocation", etc. Anyway I used a hash as the main
data structure to keep track of things. Turned out to be a more complicated project that I had first
thought - mainly due to making it work with 2 compilers each of C and C++ using the same single .h file.
Final file was somewhat north of 1,500 lines of C with a lot of C pre-processor voo-doo. Anyway turned
out to be a fun project. One C++ prof had his own version of this, but it was so slow, it was adding
20 minutes execution time to a large C++ lab! My version was so fast that it wasn't even user perceptible
and it had more features. Using a very efficient data structure was a big part of the speed improvement.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|