Article View: comp.sys.atari.st
Article #39704Re: more on strncpy (was re: laser c question)
From: John Stanley
Date: Mon, 18 Dec 1989 12:49
Date: Mon, 18 Dec 1989 12:49
38 lines
1808 bytes
1808 bytes
[kirkenda@.cs.pdx.edu (Steve Kirkendall) writes...]
>
> In article <1870@calvin.cs.mcgill.ca> depeche@calvin.cs.mcgill.ca (Sam Alan EZUST) writes:
>>someone already sent me dlibs memcpy which I believe is what is used
>>in Sozobon.... However, I don't have an assembler and am not too
>>much of an expert in it anyway, so I couldn't get it installed on
>>my system without help.
>
> Okay, here's one in C:
>
> memcpy(dest, src, count)
> register char *dest; /* destination address */
> register char *src; /* source address */
> register int count; /* number of bytes to copy */
> {
> while (--count >= 0)
> *dest++ = *src++;
> }
>
> This can copy up to 32767 bytes at a time. It isn't very fast, though.
Actualy, it can copy up to 65535 bytes if you change:
while (--count >= 0)
into
while (count-- != 0)
While the parameter passed to memcpy is usualy documented to be just an
int, it's not uncommon for versions of memcpy to treat the count variable
as an unsigned integer instead which doubles the amount to memory that
can be moved with a single call...
(Before you use this, be sure your code isn't going to have to deal
with copying negative numbers of bytes... only 1/2 :^)
---
John Stanley <dynasoft!john@stag.UUCP>
Software Consultant / Dynasoft Systems
Technical Details
Message-ID:
<1989Dec18.124932.1486@stag.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!zaphod.mps.ohio-state.edu!sunybcs!rutgers!uwvax!umn-d-ub!umn-cs!nis!pwcs!stag!daemonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!zaphod.mps.ohio-state.edu!sunybcs!rutgers!uwvax!umn-d-ub!umn-cs!nis!pwcs!stag!daemon From: john@dynasoft.UUCP (John Stanley) Newsgroups: comp.sys.atari.st Subject: Re: more on strncpy (was re: laser c question) Message-ID: <1989Dec18.124932.1486@stag.UUCP> Date: 18 Dec 89 12:49:32 GMT Sender: daemon@stag.UUCP (The devil himself) Organization: Mindtools ST Access Group Lines: 38