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

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

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

Marked as best answer by on May 01, 2025, 04:50:44 PM

Martin Hanley

  • Guest
TSendUserEvent() in C
« Reply #1 on: January 01, 1970, 12:00:00 AM »
  • Undo Best Answer
  • 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

    Martin Hanley

    • Guest
    TSendUserEvent() in C
    « Reply #3 on: January 01, 1970, 12:00:00 AM »
    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! :)