[2237] in Kerberos_V5_Development
Re: Memory allocation/freeing
daemon@ATHENA.MIT.EDU (Richard Basch)
Wed Feb 19 01:16:54 1997
Date: Wed, 19 Feb 1997 01:16:20 -0500
To: "Theodore Y. Ts'o" <tytso@MIT.EDU>
Cc: "Richard Basch" <basch@lehman.com>, krbdev@MIT.EDU
In-Reply-To: <9702190602.AA15313@dcl.MIT.EDU>
From: "Richard Basch" <basch@lehman.com>
On Wed, 19-February-1997, "Theodore Y. Ts'o" wrote to "Richard Basch, krbdev@MIT.EDU" saying:
> krb5_unparse_name() doesn't play the realloc()'ing game. Take a closer
> look at the source code; it sets *name to be NULL before calling
> krb5_unparse_name_ext(), so the realloc code path can never be called.
Ok. I missed that line in krb5_unparse_name.
> krb5_unparse_name_ext() does, but the assumption is that it is
> reallocing memory out of its own malloc() pool; note that you have to
> pass in an int * as well so it can keep track of how big the buffer is.
> The API is such that the first time you call it, you pass in a pointer
> to a char pointer that is NULL, and a pointer to an integer variable
> which is set to 0. krb5_unparse_name_ext(), then gets called
> repeatedly, with the buffer and size buffer being reallocating and
> adjusted as necessary.
Given the routine and how the realloc is done, I sure hope that it is
not generally available to application developers... Anyway, we still
need a routine to free the memory allocated by it. Suggestions?
krb5_free_name(krb5_context, char *) ?
My next question is: are there any more cases where we need to implement
a free routine?
--
Richard Basch
Sr. Developer/Analyst, DSO URL: http://web.mit.edu/basch/www/home.html
Lehman Brothers, Inc. Email: basch@lehman.com, basch@mit.edu
101 Hudson St., 38th Floor Fax: +1-201-524-5828
Jersey City, NJ 07302-3988 Voice: +1-201-524-5049