>>ITEM : N01002
>>DATE: 07/30/97
>>TYPE:
>>TITLE:
N_COMPRESS or N_DCOMPRESS cause GPF or memory fault
>>PRODUCT(S):
NetLib 2.5x for FoxPro Windows
NetLib 2.5x for FoxPro DOS
NetLib 6.5x for Clipper
>>PLATFORMS(S):
>>SUMMARY:
When repeatedly calling N_COMPRESS or N_DCOMPRESS with large buffers, the program may eventually crash with a GPF error or an "out of memory" error.
>>MORE INFORMATION:
Due to FoxPro's internal memory management, this problem occurs primarily in FoxPro. However, the recommendations below are also applicable to Clipper.
>>RESOLUTION/FIX:
- Use A_ALLOC() instead of SPACE() or REPL() to create a receive buffer for N_COMPRESS, N_DCOMPRESS.
- Add a small amount of "slack space" (about 32 bytes) to each receive buffer, since NetLib also uses the receive buffer as an internal work buffer. See example below.
>>EXAMPLE(S):
** Before...
cIn = A->memo
nLen = LEN(cIn)
cOut = SPACE(nLen)
nLen = N_COMPRESS(cIn, @cOut, nLen)
REPLACE A->memo WITH LEFT(cOut,nLen)
** After ...
#define SLACK_SPACE 32 && provide additional work space
cIn = A->memo
nLen = LEN(cIn)
Out = A_ALLOC(nLen+SLACK_SPACE)
nLen = N_COMPRESS(cIn,Out,nLen)
REPLACE A->memo WITH A_STRING(Out,nLen)
=A_FREE(Out)
>>SEE ALSO:
>>COPYRIGHT 1997 Communication Horizons
All rights reserved worldwide.
No distribution without specific consent of publisher.
Knowledgebase
Top Home