shithub: qk1

Download patch

ref: 968ea5f2c3b96b5bd413534ed11789ef9026c47e
parent: 84a97807937e6e3e3edb4d36d6ee2bee32cc13c8
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Oct 13 23:19:30 EDT 2024

memcpy → memmove

--- a/qw/cl_parse.c
+++ b/qw/cl_parse.c
@@ -444,7 +444,7 @@
 	r = upload_size - upload_pos;
 	if (r > 768)
 		r = 768;
-	memcpy(buffer, upload_data + upload_pos, r);
+	memmove(buffer, upload_data + upload_pos, r);
 	MSG_WriteByte (&cls.netchan.message, clc_upload);
 	MSG_WriteShort (&cls.netchan.message, r);
 
@@ -480,7 +480,7 @@
 Con_DPrintf("Upload starting of %d...\n", size);
 
 	upload_data = malloc(size);
-	memcpy(upload_data, data, size);
+	memmove(upload_data, data, size);
 	upload_size = size;
 	upload_pos = 0;
 
@@ -885,7 +885,7 @@
 
 		dest = player->translations;
 		source = vid.colormap;
-		memcpy (dest, vid.colormap, sizeof(player->translations));
+		memmove (dest, vid.colormap, sizeof(player->translations));
 		top = player->topcolor;
 		if (top > 13 || top < 0)
 			top = 13;
@@ -898,13 +898,13 @@
 		for (i=0 ; i<VID_GRADES ; i++, dest += 256, source+=256)
 		{
 			if (top < 128)	// the artists made some backwards ranges.  sigh.
-				memcpy (dest + TOP_RANGE, source + top, 16);
+				memmove (dest + TOP_RANGE, source + top, 16);
 			else
 				for (j=0 ; j<16 ; j++)
 					dest[TOP_RANGE+j] = source[top+15-j];
 					
 			if (bottom < 128)
-				memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
+				memmove (dest + BOTTOM_RANGE, source + bottom, 16);
 			else
 				for (j=0 ; j<16 ; j++)
 					dest[BOTTOM_RANGE+j] = source[bottom+15-j];		
--- a/qw/cmd.c
+++ b/qw/cmd.c
@@ -98,7 +98,7 @@
 	if (templen)
 	{
 		temp = Z_Malloc (templen);
-		memcpy (temp, cmd_text.data, templen);
+		memmove (temp, cmd_text.data, templen);
 		SZ_Clear (&cmd_text);
 	}
 	else
@@ -144,7 +144,7 @@
 		}
 			
 				
-		memcpy (line, text, i);
+		memmove (line, text, i);
 		line[i] = 0;
 		
 // delete the text from the command buffer and move remaining commands down
@@ -157,7 +157,7 @@
 		{
 			i++;
 			cmd_text.cursize -= i;
-			memcpy (text, text+i, cmd_text.cursize);
+			memmove (text, text+i, cmd_text.cursize);
 		}
 
 // execute the command line
--- a/qw/common.c
+++ b/qw/common.c
@@ -630,7 +630,7 @@
 {
 	int bits;
 
-	memcpy (move, from, sizeof(*move));
+	memmove (move, from, sizeof(*move));
 
 	bits = MSG_ReadByte ();
 		
@@ -695,7 +695,7 @@
 
 void SZ_Write (sizebuf_t *buf, void *data, int length)
 {
-	memcpy (SZ_GetSpace(buf,length),data,length);		
+	memmove (SZ_GetSpace(buf,length),data,length);		
 }
 
 void SZ_Print (sizebuf_t *buf, char *data)
@@ -705,9 +705,9 @@
 	len = strlen(data)+1;
 
 	if (!buf->cursize || buf->data[buf->cursize-1])
-		memcpy ((byte *)SZ_GetSpace(buf, len),data,len); // no trailing 0
+		memmove ((byte *)SZ_GetSpace(buf, len),data,len); // no trailing 0
 	else
-		memcpy ((byte *)SZ_GetSpace(buf, len-1)-1,data,len); // write over trailing 0
+		memmove ((byte *)SZ_GetSpace(buf, len-1)-1,data,len); // write over trailing 0
 }
 
 
@@ -2011,7 +2011,7 @@
 
 	if (length > 60)
 		length = 60;
-	memcpy (chkbuf + 16, base, length);
+	memmove (chkbuf + 16, base, length);
 
 	length += 16;
 
@@ -2047,7 +2047,7 @@
 
 	if (length > 60)
 		length = 60;
-	memcpy (chkb, base, length);
+	memmove (chkb, base, length);
 
 	chkb[length] = (sequence & 0xff) ^ p[0];
 	chkb[length+1] = p[1];
--- a/qw/console.c
+++ b/qw/console.c
@@ -168,7 +168,7 @@
 		if (con_linewidth < numchars)
 			numchars = con_linewidth;
 
-		memcpy (tbuf, con->text, CON_TEXTSIZE);
+		memmove (tbuf, con->text, CON_TEXTSIZE);
 		memset (con->text, ' ', CON_TEXTSIZE);
 
 		for (i=0 ; i<numlines ; i++)
--- a/qw/draw.c
+++ b/qw/draw.c
@@ -280,7 +280,7 @@
 	source = pic->data;
 	dest = vid.buffer + y * vid.rowbytes + x;
 	for(v=0; v<pic->height; v++){
-		memcpy(dest, source, pic->width);
+		memmove(dest, source, pic->width);
 		dest += vid.rowbytes;
 		source += pic->width;
 	}
@@ -308,7 +308,7 @@
 	source = pic->data + srcy * pic->width + srcx;
 	dest = vid.buffer + y * vid.rowbytes + x;
 	for(v=0; v<height; v++){
-		memcpy(dest, source, width);
+		memmove(dest, source, width);
 		dest += vid.rowbytes;
 		source += pic->width;
 	}
@@ -475,7 +475,7 @@
 		dest = conback->data + 320 - (strlen(ver)*8 + 11) + 320*186;
 	}
 
-	memcpy(saveback, conback->data + 320*186, 320*8);
+	memmove(saveback, conback->data + 320*186, 320*8);
 	for (x=0 ; x<strlen(ver) ; x++)
 		Draw_CharToConback (ver[x], dest+(x<<3));
 	
@@ -485,7 +485,7 @@
 		v = (vid.conheight - lines + y) * 200 / vid.conheight;
 		src = conback->data + v * 320;
 		if(vid.conwidth == 320)
-			memcpy(dest, src, vid.conwidth);
+			memmove(dest, src, vid.conwidth);
 		else{
 			f = 0;
 			fstep = 320 * 0x10000 / vid.conwidth;
@@ -498,7 +498,7 @@
 		}
 	}
 	// put it back
-	memcpy(conback->data + 320*186, saveback, 320*8);
+	memmove(conback->data + 320*186, saveback, 320*8);
 }
 
 
@@ -543,7 +543,7 @@
 	{
 		for (i=0 ; i<prect->height ; i++)
 		{
-			memcpy (pdest, psrc, prect->width);
+			memmove (pdest, psrc, prect->width);
 			psrc += rowbytes;
 			pdest += vid.rowbytes;
 		}
--- a/qw/md4.c
+++ b/qw/md4.c
@@ -119,7 +119,7 @@
 	/* Transform as many times as possible.*/
 	if (inputLen >= partLen)
 	{
- 		memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen);
+ 		memmove((POINTER)&context->buffer[index], (POINTER)input, partLen);
  		MD4Transform (context->state, context->buffer);
 
  		for (i = partLen; i + 63 < inputLen; i += 64)
@@ -131,7 +131,7 @@
  		i = 0;
 
 	/* Buffer remaining input */
-	memcpy ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);
+	memmove ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);
 }
 
 
--- a/qw/menu.c
+++ b/qw/menu.c
@@ -133,16 +133,16 @@
 		identityTable[j] = j;
 	dest = translationTable;
 	source = identityTable;
-	memcpy (dest, source, 256);
+	memmove (dest, source, 256);
 
 	if (top < 128)	// the artists made some backwards ranges.  sigh.
-		memcpy (dest + TOP_RANGE, source + top, 16);
+		memmove (dest + TOP_RANGE, source + top, 16);
 	else
 		for (j=0 ; j<16 ; j++)
 			dest[TOP_RANGE+j] = source[top+15-j];
 
 	if (bottom < 128)
-		memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
+		memmove (dest + BOTTOM_RANGE, source + bottom, 16);
 	else
 		for (j=0 ; j<16 ; j++)
 			dest[BOTTOM_RANGE+j] = source[bottom+15-j];		
--- a/qw/model.c
+++ b/qw/model.c
@@ -96,7 +96,7 @@
 	out = decompressed;
 
 /*
-	memcpy (out, in, row);
+	memmove (out, in, row);
 */
 	if (!in)
 	{	// no vis info, so make all visible
@@ -349,13 +349,13 @@
 		tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname );
 		loadmodel->textures[i] = tx;
 
-		memcpy (tx->name, mt->name, sizeof(tx->name));
+		memmove (tx->name, mt->name, sizeof(tx->name));
 		tx->width = mt->width;
 		tx->height = mt->height;
 		for (j=0 ; j<MIPLEVELS ; j++)
 			tx->offsets[j] = mt->offsets[j] + sizeof(texture_t) - sizeof(miptex_t);
 		// the pixels immediately follow the structures
-		memcpy ( tx+1, mt+1, pixels);
+		memmove ( tx+1, mt+1, pixels);
 		
 		if (!strncmp(mt->name,"sky",3))	
 			R_InitSky (tx);
@@ -468,7 +468,7 @@
 		return;
 	}
 	loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname);	
-	memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
+	memmove (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
 }
 
 
@@ -485,7 +485,7 @@
 		return;
 	}
 	loadmodel->visdata = Hunk_AllocName ( l->filelen, loadname);	
-	memcpy (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
+	memmove (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
 }
 
 
@@ -502,7 +502,7 @@
 		return;
 	}
 	loadmodel->entities = Hunk_AllocName ( l->filelen, loadname);	
-	memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen);
+	memmove (loadmodel->entities, mod_base + l->fileofs, l->filelen);
 }
 
 
@@ -1327,7 +1327,7 @@
 	pskin = Hunk_AllocName (skinsize * r_pixbytes, loadname);
 	pinskin = (byte *)pin;
 	*pskinindex = (byte *)pskin - (byte *)pheader;
-	memcpy (pskin, pinskin, skinsize);
+	memmove (pskin, pinskin, skinsize);
 	pinskin += skinsize;
 	return ((void *)pinskin);
 }
@@ -1634,7 +1634,7 @@
 	Cache_Alloc (&mod->cache, total, loadname);
 	if (!mod->cache.data)
 		return;
-	memcpy (mod->cache.data, pheader, total);
+	memmove (mod->cache.data, pheader, total);
 
 	Hunk_FreeToLowMark (start);
 }
@@ -1673,7 +1673,7 @@
 	pspriteframe->down = origin[1] - height;
 	pspriteframe->left = origin[0];
 	pspriteframe->right = width + origin[0];
-	memcpy (&pspriteframe->pixels[0], (byte *)(pinframe + 1), size);
+	memmove (&pspriteframe->pixels[0], (byte *)(pinframe + 1), size);
 	return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size);
 }
 
--- a/qw/net_chan.c
+++ b/qw/net_chan.c
@@ -134,7 +134,7 @@
 	memset (chan, 0, sizeof(*chan));
 
 	if(adr != nil)
-		memcpy(&chan->remote_address, adr, sizeof *adr);
+		memmove(&chan->remote_address, adr, sizeof *adr);
 	chan->last_received = realtime;
 	
 	chan->message.data = chan->message_buf;
@@ -214,7 +214,7 @@
 // if the reliable transmit buffer is empty, copy the current message out
 	if (!chan->reliable_length && chan->message.cursize)
 	{
-		memcpy (chan->reliable_buf, chan->message_buf, chan->message.cursize);
+		memmove (chan->reliable_buf, chan->message_buf, chan->message.cursize);
 		chan->reliable_length = chan->message.cursize;
 		chan->message.cursize = 0;
 		chan->reliable_sequence ^= 1;
--- a/qw/net_udp.c
+++ b/qw/net_udp.c
@@ -118,7 +118,7 @@
 	if(a == cons + nelem(cons))
 		return;
 	else if(a->fd < 0){
-		memcpy(a, to, sizeof *a);
+		memmove(a, to, sizeof *a);
 		if((a->fd = dial(netmkaddr(a->addr, "udp", a->srv), nil, nil, nil)) < 0){
 			fprint(2, "dial: %r\n");
 			return;
--- a/qw/pr_cmds.c
+++ b/qw/pr_cmds.c
@@ -581,7 +581,7 @@
 	VectorAdd (ent->v.origin, ent->v.view_ofs, org);
 	leaf = Mod_PointInLeaf (org, sv.worldmodel);
 	pvs = Mod_LeafPVS (leaf, sv.worldmodel);
-	memcpy (checkpvs, pvs, (sv.worldmodel->numleafs+7)>>3 );
+	memmove (checkpvs, pvs, (sv.worldmodel->numleafs+7)>>3 );
 
 	return i;
 }
--- a/qw/r_sprite.c
+++ b/qw/r_sprite.c
@@ -65,7 +65,7 @@
 	
 // handle wraparound case
 	dists[nump] = dists[0];
-	memcpy (instep, in, sizeof (vec5_t));
+	memmove (instep, in, sizeof (vec5_t));
 
 
 // clip the winding
@@ -76,7 +76,7 @@
 	{
 		if (dists[i] >= 0)
 		{
-			memcpy (outstep, instep, sizeof (vec5_t));
+			memmove (outstep, instep, sizeof (vec5_t));
 			outstep += sizeof (vec5_t) / sizeof (float);
 			outcount++;
 		}
--- a/qw/sv_ccmds.c
+++ b/qw/sv_ccmds.c
@@ -805,7 +805,7 @@
 	}
 	strcpy(cl->uploadfn, checkname);
 
-	memcpy(&cl->snap_from, &net_from, sizeof(net_from));
+	memmove(&cl->snap_from, &net_from, sizeof(net_from));
 	if (sv_redirected != RD_NONE)
 		cl->remote_snap = true;
 	else
--- a/qw/sv_init.c
+++ b/qw/sv_init.c
@@ -181,7 +181,7 @@
 	vcount = 0;
 	for (i=0 ; i<num ; i++, scan+=rowbytes)
 	{
-		memcpy (scan, Mod_LeafPVS(sv.worldmodel->leafs+i, sv.worldmodel),
+		memmove (scan, Mod_LeafPVS(sv.worldmodel->leafs+i, sv.worldmodel),
 			rowbytes);
 		if (i == 0)
 			continue;
@@ -201,7 +201,7 @@
 	dest = (unsigned *)sv.phs;
 	for (i=0 ; i<num ; i++, dest += rowwords, scan += rowbytes)
 	{
-		memcpy (dest, scan, rowbytes);
+		memmove (dest, scan, rowbytes);
 		for (j=0 ; j<rowbytes ; j++)
 		{
 			bitbyte = scan[j];
--- a/qw/sv_send.c
+++ b/qw/sv_send.c
@@ -38,7 +38,7 @@
 		send[2] = 0xff;
 		send[3] = 0xff;
 		send[4] = A2C_PRINT;
-		memcpy (send+5, outputbuf, strlen(outputbuf)+1);
+		memmove (send+5, outputbuf, strlen(outputbuf)+1);
 
 		NET_SendPacket (strlen(send)+1, send, net_from);
 	}
@@ -706,7 +706,7 @@
 				
 				//move along, move along
 				for (j = 1; j < c->num_backbuf; j++) {
-					memcpy(c->backbuf_data[j - 1], c->backbuf_data[j],
+					memmove(c->backbuf_data[j - 1], c->backbuf_data[j],
 						c->backbuf_size[j]);
 					c->backbuf_size[j - 1] = c->backbuf_size[j];
 				}
--- a/qw/svmodel.c
+++ b/qw/svmodel.c
@@ -78,7 +78,7 @@
 	out = decompressed;
 
 	/*
-	memcpy (out, in, row);
+	memmove (out, in, row);
 	*/
 	if (!in)
 	{	// no vis info, so make all visible
@@ -293,13 +293,13 @@
 		tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname );
 		loadmodel->textures[i] = tx;
 
-		memcpy (tx->name, mt->name, sizeof(tx->name));
+		memmove (tx->name, mt->name, sizeof(tx->name));
 		tx->width = mt->width;
 		tx->height = mt->height;
 		for (j=0 ; j<MIPLEVELS ; j++)
 			tx->offsets[j] = mt->offsets[j] + sizeof(texture_t) - sizeof(miptex_t);
 		// the pixels immediately follow the structures
-		memcpy ( tx+1, mt+1, pixels);
+		memmove ( tx+1, mt+1, pixels);
 	}
 
 //
@@ -409,7 +409,7 @@
 		return;
 	}
 	loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname);	
-	memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
+	memmove (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
 }
 
 
@@ -426,7 +426,7 @@
 		return;
 	}
 	loadmodel->visdata = Hunk_AllocName ( l->filelen, loadname);	
-	memcpy (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
+	memmove (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
 }
 
 
@@ -443,7 +443,7 @@
 		return;
 	}
 	loadmodel->entities = Hunk_AllocName ( l->filelen, loadname);	
-	memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen);
+	memmove (loadmodel->entities, mod_base + l->fileofs, l->filelen);
 }
 
 
--- a/qw/zone.c
+++ b/qw/zone.c
@@ -340,7 +340,7 @@
 	//
 	// print the single block
 	//
-		memcpy (name, h->name, 8);
+		memmove (name, h->name, 8);
 		if (all)
 			Con_Printf ("%8p :%8d %8s\n",h, h->size, name);
 			
@@ -555,9 +555,9 @@
 	{
 //		Con_Printf ("cache_move ok\n");
 
-		memcpy(new+1, c+1, c->size - sizeof(cache_system_t));
+		memmove(new+1, c+1, c->size - sizeof(cache_system_t));
 		new->user = c->user;
-		memcpy(new->name, c->name, sizeof(new->name));
+		memmove(new->name, c->name, sizeof(new->name));
 		Cache_Free (c->user);
 		new->user->data = (void *)(new+1);
 	}