Eliminated a memory allocation bug

Added a sensible workaround for BSession message code packaging


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4937 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-10-03 23:28:46 +00:00
parent e956d70682
commit 8123b61c01
2 changed files with 31 additions and 8 deletions
+10 -5
View File
@@ -1,4 +1,3 @@
#include <malloc.h>
#include <ServerProtocol.h>
#include "PortLink.h"
#include "PortMessage.h"
@@ -12,7 +11,7 @@ PortLink::PortLink(port_id port)
fReceivePort=create_port(30,"PortLink reply port");
fSendCode=0;
fSendBuffer=(char*)malloc(4096);
fSendBuffer=new char[4096];
fSendPosition=4;
}
@@ -24,10 +23,15 @@ PortLink::PortLink( const PortLink &link )
fReceivePort=create_port(30,"PortLink reply port");
fSendCode = 0;
fSendBuffer = (char*)malloc(4096);
fSendBuffer=new char[4096];
fSendPosition = 4;
}
PortLink::~PortLink(void)
{
delete [] fSendBuffer;
}
void PortLink::SetOpCode( int32 code )
{
fSendCode=code;
@@ -104,7 +108,8 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE
// We got this far, so we apparently have some data
msg->SetCode(rcode);
msg->SetBuffer(rbuffer,rbuffersize,false);
msg->BSessionWorkaround();
return B_OK;
}
@@ -123,6 +128,6 @@ status_t PortLink::Attach(const void *data, size_t size)
void PortLink::MakeEmpty()
{
fSendPosition = 4;
fSendPosition=4;
}