summaryrefslogtreecommitdiffstats
path: root/K2LABI/ABI/ResultParser.cpp
blob: b5e39bc0ca0a00767c25d21a426230faaa88da44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "k2l-type.h"
#include "ResultParser.h"
#include <string.h>

BYTE* CResultParser::ToByteArray(ParamDef* pParams, int nParamCount, int& nResultLength)
{
    int nLength = 0;
    for (int i = 0; i < nParamCount; i++)
    {
        nLength += pParams[i].m_nLength;
    }

    BYTE* pBuffer = NULL;
    if (nLength)
    {
        nLength = (nLength + 1) & ~1;
        pBuffer = new BYTE[nLength];
        memset(pBuffer, 0, nLength);
        BYTE* pTemBuf = pBuffer;
        for(int i = 0; i < nParamCount; i++)
        {
            memcpy(pTemBuf, pParams[i].m_pData, pParams[i].m_nLength);
            pTemBuf += pParams[i].m_nLength;
        }
    }

    nResultLength = nLength;
    return pBuffer;
}