1/*---------------------------------------------------------------------------*
2 *  pendian.c  *
3 *                                                                           *
4 *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5 *                                                                           *
6 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7 *  you may not use this file except in compliance with the License.         *
8 *                                                                           *
9 *  You may obtain a copy of the License at                                  *
10 *      http://www.apache.org/licenses/LICENSE-2.0                           *
11 *                                                                           *
12 *  Unless required by applicable law or agreed to in writing, software      *
13 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 *  See the License for the specific language governing permissions and      *
16 *  limitations under the License.                                           *
17 *                                                                           *
18 *---------------------------------------------------------------------------*/
19
20
21
22
23
24
25#include "pendian.h"
26
27void swap_byte_order(void *buffer, size_t count, size_t itemSize)
28{
29  char *data = (char *) buffer;
30  register char *p, *q, c;
31
32  /* Process every item */
33  while (count > 0)
34  {
35    p = data;
36    q = data + itemSize - 1;
37
38    while (p < q)
39    {
40      c = *p;
41      *p++ = *q;
42      *q-- = c;
43    }
44
45    /* Prepare for next pass */
46    data += itemSize;
47    count--;
48  }
49}
50