Did this message not reach the list (or you)? -Flávio
---------- Forwarded message ---------- From: Flávio Etrusco <[EMAIL PROTECTED]> Date: Mar 31, 2006 3:12 AM Subject: Re: [lazarus] SIGSEGV error To: [email protected] > (...) > The exact processing code was: > > GetMem( lpLocalBuffer, length( strBuffer ) ); > StrPCopy( lpLocalBuffer, strBuffer ); > TopicMemoryStream.Clear; > TopicMemoryStream.WriteBuffer( lpLocalBuffer^, length( lpLocalBuffer ) ); > TopicMemoryStream.Position := 0; FreeMem( lpLocalBuffer ); > > - lpLocalBuffer is pchar var declared in var section of the function. > - strbuffer is a String. > - TopicMemoryStream is a TMemoryStream. > > (...) First thing, you must allocate lpLocalBuffer with Length(strBuffer)+1, to accomodate the #0/nil/null terminator. Actually, most of the times this code would not cause an AV/SIGSEGV but "only" change some "random" memory of your program ;-) Second, is this the whole procedure or do you need the pchar for any other manipulation? If all you do is write to the stream you can avoid the copy altogether and just pass "strBuffer[1]" (or "PChar(strBuffer)^" if you prefer...) as the parameter. -Flávio _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
