Optimization, remove memset from Rx path, verify message length in message_2_pars, do not clean entiry _cmsg structure for DATA_B3

master
MelwareDE 14 years ago
parent ba89d59907
commit be8968c915
  1. 2
      libcapi20/capi20.c
  2. 12
      libcapi20/convert.c

@ -472,8 +472,6 @@ static unsigned char *get_buffer(unsigned applid, size_t *sizep, unsigned *handl
*sizep = ap->recvbuffersize;
*handle = (buf->buf-ap->bufferstart)/ap->recvbuffersize;
memset(buf->buf, 0, ap->recvbuffersize);
return buf->buf;
}

@ -578,7 +578,9 @@ unsigned capi_cmsg2message(_cmsg * cmsg, _cbyte * msg)
/*-------------------------------------------------------*/
static void message_2_pars(_cmsg * cmsg)
{
for (; TYP != _CEND; cmsg->p++) {
_cword message_length = CAPIMSG_LEN(cmsg->m);
for (; TYP != _CEND && cmsg->l < message_length; cmsg->p++) {
switch (TYP) {
case _CBYTE:
@ -629,11 +631,15 @@ static void message_2_pars(_cmsg * cmsg)
/*-------------------------------------------------------*/
unsigned capi_message2cmsg(_cmsg * cmsg, _cbyte * msg)
{
memset(cmsg, 0, sizeof(_cmsg));
_cbyte Command;
byteTRcpy(msg + 4, &Command);
if (Command != CAPI_DATA_B3)
memset(cmsg, 0, sizeof(_cmsg));
cmsg->m = msg;
cmsg->l = 8;
cmsg->p = 0;
byteTRcpy(cmsg->m + 4, &cmsg->Command);
cmsg->Command = Command;
byteTRcpy(cmsg->m + 5, &cmsg->Subcommand);
cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)];

Loading…
Cancel
Save