2 * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
3 * You may copy, distribute, and use this software as long as this
4 * copyright statement is not removed.
9 char rcs_hdr
[] = "$Id: memory.c,v 1.2 2006-07-25 10:09:19 rt Exp $";
12 void malloc_check_data();
15 memccpy(ptr1
, ptr2
, ch
, len
)
26 * I know that the assignment could be done in the following, but
27 * I wanted to perform a check before any assignment, so first I
28 * determine the length, check the pointers and then do the assignment.
30 for( i
=0; (i
< len
) && (ptr2
[i
] != ch
); i
++)
42 malloc_check_data("memccpy", ptr1
, check
);
43 malloc_check_data("memccpy", ptr2
, check
);
46 * if we found the character...
61 *(ptr1
++) = *(ptr2
++);
75 for( i
=0; (i
< len
) && (ptr1
[i
] != (char) ch
); i
++)
79 malloc_check_data("memchr", ptr1
, i
);
92 memcpy(ptr1
, ptr2
, len
)
99 malloc_check_data("memcpy", ptr1
, len
);
100 malloc_check_data("memcpy", ptr2
, len
);
103 * while the normal memcpy does not guarrantee that it will
104 * handle overlapping memory correctly, we will try...
106 if( ptr1
> ptr2
&& ptr1
< (ptr2
+len
))
112 *(ptr1
--) = *(ptr2
--);
119 *(ptr1
++) = *(ptr2
++);
127 memcmp(ptr1
, ptr2
, len
)
128 register char * ptr1
;
129 register char * ptr2
;
132 malloc_check_data("memcpy", ptr1
, len
);
133 malloc_check_data("memcpy", ptr2
, len
);
135 while( --len
>= 0 && (*ptr1
== *ptr2
) )
142 * If stopped by len, return zero
149 return( *ptr1
- *ptr2
);
153 memset(ptr1
, ch
, len
)
154 register char * ptr1
;
160 malloc_check_data("memcpy", ptr1
, len
);
176 return(memcpy(ptr1
,ptr2
,len
));
184 return(memset(ptr1
,'\0',len
));
188 bcmp(ptr2
, ptr1
, len
)
193 return( memcmp(ptr1
,ptr2
,len
) );