Kaydet (Commit) 7d9a7020 authored tarafından Julien Nabet's avatar Julien Nabet

Good way to initialize array of char char var[NB]={0}

See http://stackoverflow.com/questions/1920430/c-array-initialization

Change-Id: Ibbbe249684dc34f8aa44868c99cc1344a2928ade
üst 7f561b9d
...@@ -497,23 +497,17 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread() ...@@ -497,23 +497,17 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
else if( pThread->maPipe.create( aPipeIdent.getStr(), osl_Pipe_OPEN, rSecurity )) // Creation not successfull, now we try to connect else if( pThread->maPipe.create( aPipeIdent.getStr(), osl_Pipe_OPEN, rSecurity )) // Creation not successfull, now we try to connect
{ {
osl::StreamPipe aStreamPipe(pThread->maPipe.getHandle()); osl::StreamPipe aStreamPipe(pThread->maPipe.getHandle());
char pReceiveBuffer[sc_nCSASeqLength + 1]; char pReceiveBuffer[sc_nCSASeqLength + 1] = {0};
int nResult = 0; int nResult = 0;
int nBytes = 0; int nBytes = 0;
int nBufSz = sc_nCSASeqLength + 1; int nBufSz = sc_nCSASeqLength + 1;
// read byte per byte // read byte per byte
pReceiveBuffer[0] = 0;
while ((nResult=aStreamPipe.recv( pReceiveBuffer+nBytes, nBufSz-nBytes))>0) { while ((nResult=aStreamPipe.recv( pReceiveBuffer+nBytes, nBufSz-nBytes))>0) {
nBytes += nResult; nBytes += nResult;
if (pReceiveBuffer[nBytes-1]=='\0') { if (pReceiveBuffer[nBytes-1]=='\0') {
break; break;
} }
} }
/* make sure the buffer is \0 terminated */
if (nBytes > 0)
{
pReceiveBuffer[nBytes-1] = 0;
}
if (rtl::OString(sc_aSendArgumentsSequence).equals(pReceiveBuffer)) if (rtl::OString(sc_aSendArgumentsSequence).equals(pReceiveBuffer))
{ {
// Pipe connected to first office // Pipe connected to first office
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment