Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.0 KiB

/*****************************************************************************
*
* ftpwith.cpp - "With" procedures
*
*****************************************************************************/
#include "priv.h"
/*****************************************************************************
*
* With_Hglob
*
* Allocate a moveable HGLOBAL of the requested size, lock it, then call
* the callback. On return, unlock it and get out.
*
* Returns the allocated HGLOBAL, or 0.
*
*****************************************************************************/
HGLOBAL With_Hglob(UINT cb, HGLOBWITHPROC pfn, LPVOID pvRef)
{
HGLOBAL hglob = GlobalAlloc(GHND, cb);
if (hglob)
{
LPVOID pv = GlobalLock(hglob);
if (pv)
{
BOOL fRc = pfn(pv, pvRef);
GlobalUnlock(hglob);
if (!fRc)
{
GlobalFree(hglob);
hglob = 0;
}
}
else
{
GlobalFree(hglob);
hglob = 0;
}
}
return hglob;
}