1
by brian
clean slate |
1 |
/* Copyright (C) 2000 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
#define IFACTOR 4
|
|
17 |
||
18 |
void
|
|
19 |
dcopy(char *chardest, char *charsrc, int size) |
|
20 |
{
|
|
21 |
register int *src, *dest, intcount ; |
|
22 |
int startcharcpy, intoffset, numints2cpy, i ; |
|
23 |
||
24 |
numints2cpy = size >> 2 ; |
|
25 |
startcharcpy = numints2cpy << 2 ; |
|
26 |
intcount = numints2cpy & ~(IFACTOR-1) ; |
|
27 |
intoffset = numints2cpy - intcount ; |
|
28 |
||
29 |
src = (int *)(((int) charsrc) + intcount*sizeof(int*)) ; |
|
30 |
dest = (int *)(((int) chardest) + intcount*sizeof(int*)) ; |
|
31 |
||
32 |
/* copy the ints */
|
|
33 |
switch(intoffset) |
|
34 |
do
|
|
35 |
{
|
|
36 |
case 0: dest[3] = src[3] ; |
|
37 |
case 3: dest[2] = src[2] ; |
|
38 |
case 2: dest[1] = src[1] ; |
|
39 |
case 1: dest[0] = src[0] ; |
|
40 |
intcount -= IFACTOR ; |
|
41 |
dest -= IFACTOR ; |
|
42 |
src -= IFACTOR ; |
|
43 |
} while (intcount >= 0) ; |
|
44 |
||
45 |
/* copy the chars left over by the int copy at the end */
|
|
46 |
for(i=startcharcpy ; i<size ; i++) |
|
47 |
chardest[i] = charsrc[i] ; |
|
48 |
}
|