admin
base
basedrv
boot
busdrv
cluster
admin
bh
clnetcfg
clusapi
clusdisk
clusexts
clusnet
clusrtl
clussprt
ext
inc
mgmt
resdll
clnetres
clusres
common
disks
dummy
dummyex
exchange
genapp
gencmd
genjob
genscript
gensvc
iis
inc
ipaddr
lkquorum
msmq
ndquorum
netname
resutils
smbshare
spooler
splsvc
alloc.cxx
alloc.hxx
clusinfo.cxx
clusinfo.hxx
debug.hxx
global.hxx
makefile
precomp.hxx
process.cxx
sources
splsvc.cxx
splsvc.def
splsvc.hxx
splsvc.rc
spooler.cxx
spooler.hxx
spltest
dirs
timesvc
dirs
resmon
service
setup
test
timeserv
utils
wmiprovider
wml
clusternet.lmhosts
clusternet.txt
coffbase.txt
dirs
ipaddr.txt
join.txt
makefil0
placefil.txt
sources.inc
cmd
crts
ddk
dload
dloadhandler
efiutil
eventlog
firmware
fs
fsrec
hals
headless
inc
mspatch
mvdm
ntdll
ntdllsym
ntos
ntsetup
pnp
published
qfe
remoteboot
screg
seaudit
strsafe
stublibs
subsys
testlockout
tools
urtl
wdmdrv
wdmlib
win32
wmi
wow64
xip
zlib
dirs
prerelease.inc
project.mk
com
developer
drivers
ds
enduser
inetcore
inetsrv
loc
mergedcomponents
multimedia
net
printscan
public
published
sdktools
shell
termsrv
tools
windows
dirs
makefil0
92 lines
1.6 KiB
C++
92 lines
1.6 KiB
C++
/*++
|
|
|
|
Copyright (c) 1996 Microsoft Corporation
|
|
All rights reserved.
|
|
|
|
Module Name:
|
|
|
|
alloc.c
|
|
|
|
Abstract:
|
|
|
|
Generic realloc code for any api that can fail with
|
|
ERROR_INSUFFICIENT_BUFFER.
|
|
|
|
Author:
|
|
|
|
Albert Ting (AlbertT) 25-Sept-1996
|
|
|
|
Revision History:
|
|
|
|
--*/
|
|
|
|
#include "precomp.hxx"
|
|
#pragma hdrstop
|
|
|
|
#include "alloc.hxx"
|
|
|
|
PBYTE
|
|
pAllocRead(
|
|
HANDLE hUserData,
|
|
ALLOC_FUNC AllocFunc,
|
|
DWORD dwLenHint,
|
|
PDWORD pdwLen OPTIONAL
|
|
)
|
|
{
|
|
ALLOC_DATA AllocData;
|
|
PBYTE pBufferOut = NULL;
|
|
DWORD dwLastError;
|
|
DWORD cbActual;
|
|
|
|
if( pdwLen ){
|
|
*pdwLen = 0;
|
|
}
|
|
|
|
if( !dwLenHint ){
|
|
|
|
DBGMSG( DBG_ERROR, ( "ReallocRead: dwLenHint = 0\n" ));
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
return FALSE;
|
|
}
|
|
|
|
AllocData.pBuffer = NULL;
|
|
AllocData.cbBuffer = dwLenHint;
|
|
|
|
for( ; ; ){
|
|
|
|
cbActual = AllocData.cbBuffer;
|
|
AllocData.pBuffer = (PBYTE)LocalAlloc( LMEM_FIXED, cbActual );
|
|
|
|
if( !AllocData.pBuffer ){
|
|
break;
|
|
}
|
|
|
|
if( !AllocFunc( hUserData, &AllocData )){
|
|
|
|
//
|
|
// Call failed.
|
|
//
|
|
dwLastError = GetLastError();
|
|
LocalFree( (HLOCAL)AllocData.pBuffer );
|
|
|
|
if( dwLastError != ERROR_INSUFFICIENT_BUFFER &&
|
|
dwLastError != ERROR_MORE_DATA ){
|
|
|
|
break;
|
|
}
|
|
} else {
|
|
|
|
pBufferOut = AllocData.pBuffer;
|
|
|
|
if( pdwLen ){
|
|
*pdwLen = cbActual;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
return pBufferOut;
|
|
}
|
|
|