[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Reg: evbuffer_add_reference()



On Sun, Nov 19, 2017 at 7:02 PM, ravi chandran <ravigct27@xxxxxxxxx> wrote:
> Hi,
>
>  For the evbuffer_add_reference() function, i am passing a data pointer
> which  is being allocated in stack using alloca() function.
> Is it valid to pass a data pointer which is pointing to data on the stack to
> evbuffer_add_reference function?
> I understand from the manual that above function don't copy the data and it
> only will keep the reference(in that is the case, if data is not immediately
> sent, will it causes any problem?)
> otherwise is it neccessary that data pointer  should always be allocated on
> heap and be passed to evbuffer_add_function().
> could some one please clarify?

It always will be a problem, because indeed like you wrote it just
stores the pointer to your data in evbuffer structure, and will use it
once somebody will try to read it.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.