All of lore.kernel.org
 help / color / mirror / Atom feed
* memory management in mlmmj
@ 2005-03-23 21:28 Morten K. Poulsen
  2005-03-23 22:44 ` Christian Laursen
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Morten K. Poulsen @ 2005-03-23 21:28 UTC (permalink / raw)
  To: mlmmj

Memory management makes up quite a large portion of the code, especially
freeing memory at error conditions. How about we sacrifice a tiny bit of memory
and performance and automate it?

The basic idea here is to have scopes of dynamic memory, a lot like local
variables. At the beginning of each function we could begin a scope, and at the
end of a function (and at returns) we could end it. If we need to return a
pointer to some memory, we could move that chunk of memory up to the parent
scope. I think that would work well, and make the code a lot more readable.

It is not new, I think PHP does something like this (where a request is the
scope).

I have made a small proof of concept:
http://www.afdelingp.dk/files/memory.c

MEM_BEGIN opens a new scope.
MEM_END closes the current scope.
MEM_SAVE(ptr) moves a chunk of memory to the parent scope.

mymalloc() and myfree() works as usual.

Is it a bad idea?

Morten

-- 
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-03-29  9:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-23 21:28 memory management in mlmmj Morten K. Poulsen
2005-03-23 22:44 ` Christian Laursen
2005-03-24  0:38 ` Mads Martin Joergensen
2005-03-24  8:04 ` Mads Toftum
2005-03-24  8:07 ` Mads Martin Joergensen
2005-03-24  8:11 ` Mads Toftum
2005-03-24  8:14 ` Mads Martin Joergensen
2005-03-29  9:24 ` Morten K. Poulsen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.