1 /* bcopy.c -- copy memory.
3 Copyright (C) 1992-2024 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
24 /* Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. */
27 bcopy (void const *source0
, void *dest0
, size_t length
)
29 char const *source
= source0
;
32 /* Moving from low mem to hi mem; start at end. */
33 for (source
+= length
, dest
+= length
; length
; --length
)
35 else if (source
!= dest
)
36 /* Moving from hi mem to low mem; start at beginning. */
37 for (; length
; --length
)