从指针复制到指针 [英] copy from pointer to pointer

查看:89
本文介绍了从指针复制到指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个大块数据的快速原始副本从一个指针转移到

另一个。

Marshal.Copy让我从指针复制到数组另一个电话可以从aray到指针获得
。这显然不是最佳的。


但是我无法找到任何方法将数据的BLOCKS从指针复制到

指针......除了循环和一大堆复制指令。


将大块数据从这里复制到那里的方法是什么

给出两个指针?

....嗯..我想我可以制作一个非托管的c ++函数并做一个memcpy,但是

看起来有点奇怪

I need to make a quick raw copy of a large block of data from one pointer to
another.
Marshal.Copy let me copy from pointer to array and another call can take it
from aray to pointer. That is obviously not optimal.

I can however not find any way of copying BLOCKS of data from pointer to
pointer... apart from a loop and a load of copy instructions.

What is the method for copying a large block of data from here to there
given two pointers?
....hm.. I guess I could make an unmanaged c++ function and do a memcpy, but
that seems a bit odd

推荐答案

>我需要从一个指针到
>I need to make a quick raw copy of a large block of data from one pointer to

>另一个指针制作一个大块数据的快速原始副本。 br />Marshal.Copy让我从指针复制到数组,另一个调用可以将它从aray转移到指针。这显然不是最佳的。

然而,我无法找到任何方法将数据的BLOCKS从指针复制到
指针...除了循环和一堆复制指令。将大块数据从这里复制到那里的方法是什么?给出了两个指针?
......嗯..我想我可以创建一个非托管的c ++函数并且做一个memcpy,但
看起来有点奇怪
>another.
Marshal.Copy let me copy from pointer to array and another call can take it
from aray to pointer. That is obviously not optimal.

I can however not find any way of copying BLOCKS of data from pointer to
pointer... apart from a loop and a load of copy instructions.

What is the method for copying a large block of data from here to there
given two pointers?
...hm.. I guess I could make an unmanaged c++ function and do a memcpy, but
that seems a bit odd



你可以用PInvoke调用kernel32.dll中的RtlMoveMemory。


[DllImport(" kernel32.dll")]

static extern void RtlMoveMemory(IntPtr dest,IntPtr src,uint len);

Mattias


-

Mattias Sj?gren [C#MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com

请回复到新闻组。

You can call RtlMoveMemory in kernel32.dll with PInvoke.

[DllImport("kernel32.dll")]
static extern void RtlMoveMemory(IntPtr dest, IntPtr src, uint len);
Mattias

--
Mattias Sj?gren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


你可以用PInvoke调用kernel32.dll中的RtlMoveMemory。
You can call RtlMoveMemory in kernel32.dll with PInvoke.

>

[DllImport(" kernel32.dll")]

static extern void RtlMoveMemory( IntPtr dest,IntPtr src,uint len);
>
[DllImport("kernel32.dll")]
static extern void RtlMoveMemory(IntPtr dest, IntPtr src, uint len);



好​​..不包装c ++而是调用win32。它有点不那么凌乱,但是仍然是... b $ b仍然......在c#中真的没有本地方式吗?当一个人可以写入不安全的代码并通过指针移动数据时,在语言/框架中有一些允许块复制的功能似乎很自然


从指针到指针的



哦......你给了一个解决方案。谢谢。我会尝试。毕竟,它是

clean _enough_并且应该有效:-)

Ok.. Not wrapping c++ but invoking win32. It is a little less messy, but
still... Is there really no native way of doing this in c#? When one can
write unsafe code and move data arround through pointers, it seems natural
to have some featurein the language/framework which allows for a block copy
from pointer to pointer?

Oh well... you gave a solution. Thanks. I will try it. After all, it is
clean _enough_ and should work :-)


Jason Who < a@b.dewrote in message

news:46 ********************** @ dreader2.cybercity.d k。 ..
"Jason Who" <a@b.dewrote in message
news:46**********************@dreader2.cybercity.d k...

Ok ..不包装c ++但调用win32。它有点不那么凌乱,但是仍然是... b $ b仍然......在c#中真的没有本地方式吗?当一个人可以写出不安全的代码并通过指针移动数据时,看起来很自然

在语言/框架中有一些功能允许一个块

从指针复制到指针?
Ok.. Not wrapping c++ but invoking win32. It is a little less messy, but
still... Is there really no native way of doing this in c#? When one can
write unsafe code and move data arround through pointers, it seems natural
to have some featurein the language/framework which allows for a block
copy from pointer to pointer?



我认为同样的事情却找不到任何东西。我想知道我是否错过了b $ b缺少的东西,但有3个人在这里确认了同样的事情我想

我不是。

Michael

I thought the same thing but couldn''t find anything. I''d wondered if I was
missing something but with 3 people confirming the same thing here I guess
I''m not.

Michael


这篇关于从指针复制到指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆