[Dovecot] PATCH: mysql authentication

Matthew Reimer mreimer at vpop.net
Fri Oct 3 14:15:24 EEST 2003


Timo Sirainen wrote:
> On Fri, 2003-10-03 at 19:54, Matthew Reimer wrote:
>>One question about how t_strdup works. How and who should memory 
>>returned by t_strdup be freed? My patch has a function my_get_str() 
>>which returns the value of t_strdup, and then I do this:
>>
>>     user.uid = atoi(my_get_str(res, row, "uid")); /* XXX leak */
>>     user.gid = atoi(my_get_str(res, row, "gid")); /* XXX leak */
>>
>>Will this result in a memory leak?
> 
> 
> No.
> 
> Memory allocated by t_*() functions are freed "later". There's first
> t_push(), then you allocate memory, then t_pop() frees it all. So they
> never leak memory, but they could allocate more memory than necessary if
> called inside loop. That can be fixed by adding t_push/t_pop calls
> there.

Nice!

Thanks for the answer Timo.

Matt



More information about the dovecot mailing list