xref: /openbsd/gnu/usr.bin/texinfo/lib/memcpy.c (revision a1acfa9b)
1*a1acfa9bSespie /* Copyright (C) 1995, 1997, 2000, 2003 Free Software Foundation, Inc.
23fb98d4aSespie 
33fb98d4aSespie    This program is free software; you can redistribute it and/or modify
43fb98d4aSespie    it under the terms of the GNU General Public License as published by
53fb98d4aSespie    the Free Software Foundation; either version 2, or (at your option)
63fb98d4aSespie    any later version.
73fb98d4aSespie 
83fb98d4aSespie    This program is distributed in the hope that it will be useful,
93fb98d4aSespie    but WITHOUT ANY WARRANTY; without even the implied warranty of
103fb98d4aSespie    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
113fb98d4aSespie    GNU General Public License for more details.
123fb98d4aSespie 
133fb98d4aSespie    You should have received a copy of the GNU General Public License
143fb98d4aSespie    along with this program; if not, write to the Free Software Foundation,
153fb98d4aSespie    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
163fb98d4aSespie 
173fb98d4aSespie /* Written by Jim Meyering <meyering@na-net.ornl.gov>.  */
183fb98d4aSespie 
193fb98d4aSespie #if HAVE_CONFIG_H
203fb98d4aSespie # include <config.h>
213fb98d4aSespie #endif
223fb98d4aSespie 
23*a1acfa9bSespie #include <stddef.h>
24*a1acfa9bSespie 
25840175f0Skstailey /* Copy LEN bytes starting at SRCADDR to DESTADDR.  Result undefined
26840175f0Skstailey    if the source overlaps with the destination.
27840175f0Skstailey    Return DESTADDR. */
28840175f0Skstailey 
29*a1acfa9bSespie void *
memcpy(void * destaddr,void const * srcaddr,size_t len)30*a1acfa9bSespie memcpy (void *destaddr, void const *srcaddr, size_t len)
31840175f0Skstailey {
32840175f0Skstailey   char *dest = destaddr;
33*a1acfa9bSespie   char const *src = srcaddr;
34840175f0Skstailey 
35840175f0Skstailey   while (len-- > 0)
36*a1acfa9bSespie     *dest++ = *src++;
37*a1acfa9bSespie   return destaddr;
38840175f0Skstailey }
39