From 62afb2c44bba6118846d5509a4f72f0dd5d17227 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Sat, 25 Aug 2018 15:12:04 -0700 Subject: [PATCH] Changed most instances of memcpy() to memmove(). The sole remainder is one of _fmemcpy() in the DOS interface code. --- src/common/fastmem.c | 11 +++++------ src/common/quetzal.c | 1 - src/curses/ux_audio.c | 2 +- src/sdl/sf_aiffwav.c | 6 +++--- src/sdl/sf_font3.c | 2 +- src/sdl/sf_fonts.c | 12 ++++++------ src/sdl/sf_images.c | 2 +- src/sdl/sf_util.c | 2 +- src/sdl/sf_video.c | 6 +++--- 9 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/common/fastmem.c b/src/common/fastmem.c index 8ad1ee8..0f1c39e 100644 --- a/src/common/fastmem.c +++ b/src/common/fastmem.c @@ -33,7 +33,6 @@ #define malloc(size) farmalloc (size) #define realloc(size,p) farrealloc (size,p) #define free(size) farfree (size) -#define memcpy(d,s,n) _fmemcpy (d,s,n) #else @@ -476,7 +475,7 @@ void init_undo (void) if (undo_mem != NULL) { prev_zmp = undo_mem; undo_diff = undo_mem + h_dynamic_size; - memcpy (prev_zmp, zmp, h_dynamic_size); + memmove (prev_zmp, zmp, h_dynamic_size); } else f_setup.undo_slots = 0; @@ -877,13 +876,13 @@ int restore_undo (void) /* undo possible */ - memcpy (zmp, prev_zmp, h_dynamic_size); + memmove (zmp, prev_zmp, h_dynamic_size); SET_PC (curr_undo->pc); sp = stack + STACK_SIZE - curr_undo->stack_size; fp = stack + curr_undo->frame_offset; frame_count = curr_undo->frame_count; mem_undiff ((zbyte *) (curr_undo + 1), curr_undo->diff_size, prev_zmp); - memcpy (sp, (zbyte *)(curr_undo + 1) + curr_undo->diff_size, + memmove (sp, (zbyte *)(curr_undo + 1) + curr_undo->diff_size, curr_undo->stack_size * sizeof (*sp)); curr_undo = curr_undo->prev; @@ -1040,8 +1039,8 @@ int save_undo (void) p->diff_size = diff_size; p->stack_size = stack_size; p->frame_offset = fp - stack; - memcpy (p + 1, undo_diff, diff_size); - memcpy ((zbyte *)(p + 1) + diff_size, sp, stack_size * sizeof (*sp)); + memmove (p + 1, undo_diff, diff_size); + memmove ((zbyte *)(p + 1) + diff_size, sp, stack_size * sizeof (*sp)); if (!first_undo) { p->prev = NULL; diff --git a/src/common/quetzal.c b/src/common/quetzal.c index e687075..31f3f13 100644 --- a/src/common/quetzal.c +++ b/src/common/quetzal.c @@ -29,7 +29,6 @@ #define malloc(size) farmalloc (size) #define realloc(size,p) farrealloc (size,p) #define free(size) farfree (size) -#define memcpy(d,s,n) _fmemcpy (d,s,n) #else diff --git a/src/curses/ux_audio.c b/src/curses/ux_audio.c index a4770eb..7b1e2d4 100644 --- a/src/curses/ux_audio.c +++ b/src/curses/ux_audio.c @@ -602,7 +602,7 @@ void *playaiff(EFFECT *raw_effect) stereoize(bleep_buffer.samples, floatbuffer2, src_data.output_frames_gen); } else { /* It's already stereo. Just copy the buffer. */ - memcpy(bleep_buffer.samples, floatbuffer2, sizeof(float) * src_data.output_frames_gen * 2); + memmove(bleep_buffer.samples, floatbuffer2, sizeof(float) * src_data.output_frames_gen * 2); } /* Adjust volume. */ diff --git a/src/sdl/sf_aiffwav.c b/src/sdl/sf_aiffwav.c index 8b9c8e3..e14ef44 100644 --- a/src/sdl/sf_aiffwav.c +++ b/src/sdl/sf_aiffwav.c @@ -292,11 +292,11 @@ static void writeRIFFheader( unsigned char *f, int freq, int numsamples, int num int bytespersample){ // write header // offset 0 - memcpy(f,"RIFF",4); f += 4; + memmove(f,"RIFF",4); f += 4; // offset 4 PCwrite4(f,(36+numsamples*numchannels*bytespersample)); // offset 8 - memcpy(f,"WAVEfmt ",8); f += 8; + memmove(f,"WAVEfmt ",8); f += 8; // offset 16 PCwrite4(f,16); // offset 20 @@ -312,7 +312,7 @@ static void writeRIFFheader( unsigned char *f, int freq, int numsamples, int num // offset 34 PCwrite2(f,(8*bytespersample)); // offset 36 - memcpy(f,"data",4); f += 4; + memmove(f,"data",4); f += 4; // offset 40 PCwrite4(f,(numsamples*numchannels*bytespersample)); // offset 44 diff --git a/src/sdl/sf_font3.c b/src/sdl/sf_font3.c index 2220993..053a890 100644 --- a/src/sdl/sf_font3.c +++ b/src/sdl/sf_font3.c @@ -125,7 +125,7 @@ static SF_glyph * mygetglyph(SFONT *s, word c, int allowdef) c = 32; } src = Zfont3+8*(c-32); - memcpy(&(myglyph.bitmap[0]),src,8); + memmove(&(myglyph.bitmap[0]),src,8); myglyph.h = 8; return (SF_glyph *)&myglyph; } diff --git a/src/sdl/sf_fonts.c b/src/sdl/sf_fonts.c index cc9a183..2d236a5 100644 --- a/src/sdl/sf_fonts.c +++ b/src/sdl/sf_fonts.c @@ -165,7 +165,7 @@ static SF_bdffont *sBDXload( FILE *f, int *err, int *size, int MAXCHAR){ font = calloc(1,totb); if (!font) ERRET(-3) // errorexit(99,"malloc()\n"); //printf("allocated: %p-%p\n",font,((byte *)font)+totb); -// memcpy(&(font->magic[0]),"gBDX",4); +// memmove(&(font->magic[0]),"gBDX",4); font->minchar = minch; font->maxchar = maxch; font->defchar = defchar; @@ -174,9 +174,9 @@ static SF_bdffont *sBDXload( FILE *f, int *err, int *size, int MAXCHAR){ pbeg = (byte *)font; po = (byte *)(&(font->glyphs[maxch-minch+1])); k = strlen(fontname)+1; - memcpy(po,fontname,k); po += k; if (fngot) free(fontname); + memmove(po,fontname,k); po += k; if (fngot) free(fontname); k = strlen(copyright)+1; - memcpy(po,copyright,k); po += k; if (cpgot) free(copyright); + memmove(po,copyright,k); po += k; if (cpgot) free(copyright); for (i=minch;i<=maxch;i++) font->glyphs[i-minch] = 0; // second pass @@ -758,7 +758,7 @@ void sf_initfonts() if (!emph) os_fatal("malloc() failure in initfonts()"); Emph = makefont(emph); if (!Emph) os_fatal("malloc() failure in initfonts()"); - memcpy (emph, norm, size); + memmove (emph, norm, size); // emphasize (underline)... cfont = (byte *)emph; for (i = norm->minchar;i <= norm->maxchar;i++){ @@ -773,7 +773,7 @@ void sf_initfonts() if (!bold) os_fatal("malloc() failure in initfonts()"); Bold = makefont(bold); if (!Bold) os_fatal("malloc() failure in initfonts()"); - memcpy (bold, norm, size); + memmove (bold, norm, size); // boldify... cfont = (byte *)bold; for (i = norm->minchar;i <= norm->maxchar;i++){ @@ -792,7 +792,7 @@ void sf_initfonts() if (!bemp) os_fatal("malloc() failure in initfonts()"); Bemp = makefont(bemp); if (!Bemp) os_fatal("malloc() failure in initfonts()"); - memcpy (bemp, bold, size); + memmove (bemp, bold, size); // emphasize (underline)... cfont = (byte *)bemp; for (i = norm->minchar;i <= norm->maxchar;i++){ diff --git a/src/sdl/sf_images.c b/src/sdl/sf_images.c index 28b6a1b..d0a2848 100644 --- a/src/sdl/sf_images.c +++ b/src/sdl/sf_images.c @@ -53,7 +53,7 @@ static void readPNGData( png_structp png_ptr, png_bytep data, png_size_t length) { PNGData* pngData = (PNGData*)png_get_io_ptr(png_ptr); - memcpy(data,pngData->gfxData+pngData->offset,length); + memmove(data,pngData->gfxData+pngData->offset,length); pngData->offset += length; } diff --git a/src/sdl/sf_util.c b/src/sdl/sf_util.c index 4ff43d9..f742dfa 100644 --- a/src/sdl/sf_util.c +++ b/src/sdl/sf_util.c @@ -892,7 +892,7 @@ static int myunzip( int csize, byte *cdata, byte *udata) unsigned myin( void *d, byte **b){return 0;} int myout( void *d, byte *b, unsigned n) { - memcpy(udata,b,n); udata += n; + memmove(udata,b,n); udata += n; return 0; } diff --git a/src/sdl/sf_video.c b/src/sdl/sf_video.c index 1a4b047..714588d 100644 --- a/src/sdl/sf_video.c +++ b/src/sdl/sf_video.c @@ -334,7 +334,7 @@ static void scroll( int x, int y, int w, int h, int n) { while (nmove--) { - memcpy(dst,src,w*sizeof(ulong)); + memmove(dst,src,w*sizeof(ulong)); dst += step; src += step; } @@ -1102,7 +1102,7 @@ ulong * sf_savearea( int x, int y, int w, int h) s = sbuffer+x+y*sbpitch; for (i=0;i