• C#内存复制与比较


    比较:

     public static extern int comp2(byte[] a, byte[] b, int count);
            [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            static extern int memcmp(byte[] b1, byte[] b2, UIntPtr count);
            [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            static extern int memcmp(IntPtr ptr1, IntPtr ptr2, int count);
            [DllImport("msvcrt.dll",  CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            static extern unsafe int memcmp(void* ptr1, void* ptr2, int count);

    复制:

       [DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            public static extern IntPtr memcpy(IntPtr dest, IntPtr src, UIntPtr count);
            [DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
            public static extern IntPtr MemCopy(byte[] dest, byte[] src, UIntPtr count);
     

    还有一个复制的方法:

     System.Runtime.InteropServices.Marshal.Copy(buffer, bytes, 0, size)
     

  • 相关阅读:
    OneProxy与其它数据库中间件的对比
    防御式编程
    google jam 比赛题(设计有问题)
    Python 代码性能优化技巧
    Python性能鸡汤
    如何避免重构带来的危险
    Linux/Unix工具与正则表达式的POSIX规范
    代码抽象层次2
    chinaunix:腾讯面试题
    C++异常处理小例
  • 原文地址:https://www.cnblogs.com/81/p/2289025.html
Copyright © 2020-2023  润新知