Ignore:
Timestamp:
Dec 29, 1999, 3:37:19 PM (26 years ago)
Author:
sandervl
Message:

PostMessage memory leak fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibmsg.cpp

    r2246 r2250  
    1 /* $Id: oslibmsg.cpp,v 1.17 1999-12-29 12:39:44 sandervl Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.18 1999-12-29 14:37:16 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    124124ULONG TranslateWinMsg(ULONG msg, BOOL fMinFilter)
    125125{
    126  POSTMSG_PACKET *packet;
    127 
    128126    if(msg == 0)
    129127        return 0;
     
    235233    } while (eaten);
    236234  }
    237   OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode);
     235  OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode, MSG_REMOVE);
    238236  return rc;
    239237}
     
    287285  }
    288286
    289   OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode);
     287  OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE);
    290288  //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
    291289  if(fRemove & PM_REMOVE_W) {
     
    366364//******************************************************************************
    367365//******************************************************************************
    368 BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
    369 {
    370   return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
    371 }
    372 //******************************************************************************
    373 //******************************************************************************
    374 ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
    375 {
    376   return (ULONG)WinSendMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
     366ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
     367{
     368 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     369
     370    packet->Msg    = msg;
     371    packet->wParam = wParam;
     372    packet->lParam = lParam;
     373
     374    return (ULONG)WinSendMsg(hwnd, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
    377375}
    378376//******************************************************************************
     
    380378ULONG OSLibWinBroadcastMsg(ULONG msg, ULONG wParam, ULONG lParam, BOOL fSend)
    381379{
    382   return WinBroadcastMsg(HWND_DESKTOP, msg, (MPARAM)wParam, (MPARAM)lParam,
    383                          (fSend) ? BMSG_SEND : BMSG_POST);
    384 }
    385 //******************************************************************************
    386 //******************************************************************************
    387 BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam)
     380    return WinBroadcastMsg(HWND_DESKTOP, msg, (MPARAM)wParam, (MPARAM)lParam,
     381                           (fSend) ? BMSG_SEND : BMSG_POST);
     382}
     383//******************************************************************************
     384//******************************************************************************
     385BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
     386{
     387 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     388
     389    packet->Msg = msg;
     390    packet->wParam = wParam;
     391    packet->lParam = lParam;
     392    return WinPostMsg(hwnd, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
     393}
     394//******************************************************************************
     395//******************************************************************************
     396BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
    388397{
    389398 THDB *thdb = GetTHDBFromThreadId(threadid);
     399 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    390400
    391401    if(thdb == NULL) {
     
    393403        return FALSE;
    394404    }
    395     return WinPostQueueMsg(thdb->hmq, msg, (MPARAM)wParam, (MPARAM)lParam);
    396 }
    397 //******************************************************************************
    398 //******************************************************************************
    399 
     405    dprintf(("PostThreadMessageA %x %x %x %x", threadid, msg, wParam, lParam));
     406    packet->Msg = msg;
     407    packet->wParam = wParam;
     408    packet->lParam = lParam;
     409    return WinPostQueueMsg(thdb->hmq, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
     410}
     411//******************************************************************************
     412//******************************************************************************
     413
Note: See TracChangeset for help on using the changeset viewer.