Re: thoughts on memory usage...

From: Michael O'Reilly <michael@dont-contact.us>
Date: 21 Aug 1997 14:36:03 +0800

Duane Wessels <wessels@nlanr.net> writes:
> I've been lurking. I'm trying to catch up on email after spending
> a week writing some papers.
>
> Its probably not necessary to compress StoreEntry->key. That should
> only be different from StoreEntry->url while a request is in progress.
>
> Initially I was going to suggest that we always leave StoreEntry->url
> compressed and change every reference of entry->url with
> DECODE(entry->url). But then things become complicated if you ever
> need to do:
>
> foo(.., DECODE(e1->url), DECODE(e2->url), ...)
>
> because you can't just decode into a static array (i.e. like
> inet_ntoa() does).

You can actually get away with this, there's a disgusting trick you do
to make it work (mostly).

What you do it rotate a set of static arrays. I.e.

char * DECODE(char * url)
{
        static char foo[10][255];
        static index = 0;
        
        char * ret;

        ret = foo[index];
        index = (index + 1) % 10;
        decode_info_buffer(ret, url);
        return ret;
}

Which does what you're looking for 99% of the time.... :)

assuming you stay aware of it dangers, it mightn't be a bad thing to
do..

Michael
Received on Tue Jul 29 2003 - 13:15:42 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:24 MST