Article View: comp.std.c
Article #1745Re: memcpy
From: Timothy Murphy
Date: Sat, 22 Sep 1990 10:17
Date: Sat, 22 Sep 1990 10:17
30 lines
1300 bytes
1300 bytes
In <18083@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >In article <1990Sep19.021418.11574@maths.tcd.ie> tim@maths.tcd.ie (Timothy Murphy) writes: >>In [unix] unzip.c it is assumed that the effect of >> buf[0] = c; >> memcpy(buf+1, buf, 20); >>is to set >> buf[0] = buf[1] = buf[2] = ... = buf[21] = c. >This is incorrect. The proper way to achieve that effect is > memset(buf, c, 21); I'm afraid I oversimplified my example. The intention in unix unzip.c was to repeat *any* seqence, not just a single character, eg buf[0] = a; buf[1] = b; memcpy(buf+2, buf, 20); is intended to set buf[0] = buf[2] = buf[4] = ... = a; buf[1] = buf[3] = buf[5] = ... = b; Incidentally, it's been pointed out to me that this problem has been fixed in more recent versions of unix unzip.c . -- Timothy Murphy e-mail: tim@maths.tcd.ie
Technical Details
Message-ID:
<1990Sep22.101730.25261@maths.tcd.ie>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!maths.tcd.ie!timReferences:
<1990Sep19.021418.11574@maths.tcd.ie> <18083@haddock.ima.isc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!maths.tcd.ie!tim From: tim@maths.tcd.ie (Timothy Murphy) Newsgroups: comp.std.c Subject: Re: memcpy Keywords: memcpy Message-ID: <1990Sep22.101730.25261@maths.tcd.ie> Date: 22 Sep 90 10:17:30 GMT References: <1990Sep19.021418.11574@maths.tcd.ie> <18083@haddock.ima.isc.com> Organization: Dept. of Maths, Trinity College, Dublin, Ireland. Lines: 30