[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] problem with memory leaks
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] problem with memory leaks |
Date: |
Tue, 15 Mar 2011 13:43:35 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.32-trunk-vserver-amd64; KDE/4.4.5; x86_64; ; ) |
Hi!
While I don't see anything directly wrong, the better method would have been:
MHD_create_response_from_buffer (strlen(page.c_str()), page.c_str(),
MHD_RESPMEM_MUST_COPY);
Overall, I suggest you use valgrind on your app, maybe the leak is entirely
elsewhere?
Happy hacking,
Christian
On Tuesday 15 March 2011 09:45:49 Ondřej Odcházel wrote:
> Hi,
>
> I am confused with the way, how to create dynamic string at function
> "answer_to_connection" without memory leaks. I generate some "string
> page" and want to pass it like
>
> string page = getSomeRandomString();
> struct MHD_Response *response;
> int ret;
> response = MHD_create_response_from_data (strlen(page.c_str()),
> strdup(page.c_str()), MHD_YES, MHD_YES);
> ret = MHD_queue_response (connection, status_code, response);
> MHD_destroy_response (response);
> return ret;
>
> but i have problems with memory leaks. Do you know, where the problem can
> be?
>
> Thanks,
>
> Ondra