C Coding Tip - Self-Manage Memory Alllocation
An anonymous reader inputs: "The C programming language defines two standard memory management functions: malloc() and free(). C programmers frequently use those functions to allocate buffers at run time to pass data between functions. In many situations, however, you cannot predetermine the actual sizes required for the buffers, which may cause several fundamental problems for constructing complex C programs. This article advocates a self-managing, abstract data buffer. It outlines a pseudo-C implementation of the abstract buffer and details the advantages of adopting this mechanism."
This article, I believe, has already been published in the well known programmers' journal "No shit Sherlock - monthly"
Just like slashdot allocated extra space for the third "l" in "alllocation".
Now, I'll need a nice short catchy name for it... oh! I know! I'll call it a heap!
From the article:
pLostBlock?!? This almost sounds as if it's designed to leak!
-- MarkusQ
P.S. Seriously, I think this is a fine idea, if not particularly earth shaking. But the typo was too ironic not to point out.
> Which means you don't have predictable destruction. Which means you don't have destructors.
... ...
My GC does something like this:
1) Allocate memory, reference count 1
N-1) When ref count reaches 0, we call destroy() on the object
N) Free the memory
Marxist evolution is just N generations away!
How about this: Solve all of your memory management problems by switching to visual basic! All memory management is done automagically. No need to even think about it! Just hook up your data bound controls and write your logic code. No more memory worries :)