|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Keean Schupke (keean
fry-it.com)
Date: Mon Nov 26 2007 - 01:38:59 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
so, why in dict_db, are some of the values copied before being returned?
result = SCOPY(dict_db->val_buf, db_value.data, db_value.size);
Also, isn't that bad if I want to swap the backend for one that uses
an SQL database and does not keep a compete copy of the map in memory?
Would it not be better to standardize on copying the value before
returning, and making the caller responsible for freeing... that way
it supports db backends that do not keep data in memory the whole
time?
Regards,
Keean Schupke, Fry-IT Ltd.
On 26/11/2007, Wietse Venema <wietse
porcupine.org> wrote:
> Keean Schupke:
> > who is responsible for freeing the data pointed to by the return value
> > from dict_get?
>
> The data is owned by the lookup table.
>
> That's why the result is returned as
>
> const char *
>
> Generally, that is a strong hint that the caller can't modify, let
> alone delete, the result.
>
> > To me it looks like verify.c leaks raw_data for every dict lookup (as
> > dict_get cannot know when the returned raw_data pointer goes out of
> > scope) as there is never any "free" called on it.
>
> Purify and valgrind disagree with you.
>
> Wietse
>
> > Is this a bug, or am I misunderstanding something?
> >
> > Regards,
> > Keean Schupke, Fry-IT Ltd.
> >
> >
>
>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]