" /> TSendUserEvent() in C - Genesys CTI User Forum

Author Topic: TSendUserEvent() in C  (Read 3308 times)

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Martin Hanley

  • Guest
TSendUserEvent() in C
« on: January 01, 1970, 12:00:00 AM »
Advertisement
I'm having a bit of trouble getting a C program to send an event using TSendUserEvent(). I'm getting a protection fault from within the call, so clearly I've not set up the call properly, but am at a loss to explain what I've done wrong.

The code extract is as follows:

void ctiCloseNotReadyStatistic(char *statName)
{
TEvent event;
TKVList *user_data = TKVListCreate();

event.Event = EventUserEvent;
event.Server = g_cti_tserver; // global TServer g_cti_tserver

TKVListAddString(user_data, statName, "");
event.UserData = user_data;

TSendUserEvent(g_cti_tserver, g_this_extension, &event);

TKVListFree(user_data);
}

Any ideas?

Cheers,
Martin

Martin Hanley

  • Guest
TSendUserEvent() in C
« Reply #1 on: January 01, 1970, 12:00:00 AM »
It appears that the problem is in the freeing of the user_data structure. I guess it's some sort of timing problem, and removing TKVListFree() removes the problem.

However, this would mean that the memory would never be freed up. Solution, anyone?

Cheers,
Martin

LeszekM

  • Guest
TSendUserEvent() in C
« Reply #2 on: January 01, 1970, 12:00:00 AM »
I would clear the memory (with zeroes) occupied by the event structure before setting the fields in that variable.

In my opinion the "TSendUserEvent" function can be trying to use values from the uninitialised memory.

Regards,
Leszek

Marked as best answer by on Today at 11:59:10 PM

Martin Hanley

  • Guest
TSendUserEvent() in C
« Reply #3 on: January 01, 1970, 12:00:00 AM »
  • Undo Best Answer
  • Leszek,

    That's better!

    Thank you,
    Martin

    Rodrigo

    • Guest
    Re: TSendUserEvent() in C
    « Reply #4 on: July 18, 2009, 01:45:33 AM »
    I had same Issue, it was solved memory.
    memset (&event, 0, sizeof (event));

    Thank you! :)