Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Which is faster memmove or memcpy?

Name: Anonymous 2009-06-17 13:22

Name: Anonymous 2009-06-17 13:24

memcpy.

Glad I could help you with your homework.

Name: Anonymous 2009-06-17 13:26

inlined memcpy tends to get optimized really well.

Name: Anonymous 2009-06-17 13:31

memmove involves a temporary buffer, of course memcpy is faster. look at the man pages you idort

Name: Anonymous 2009-06-17 14:56

Their both aliased to bcopySorry for the real answer.

Name: Anonymous 2009-06-17 15:07

>>5
Conforming to
4.3BSD. This function is deprecated (marked as LEGACY in POSIX.1-2001): use memcpy() or memmove() in new programs. Note that the first two parameters are interchanged for memcpy() and memmove().

Name: Anonymous 2009-06-17 15:10

>>5
What about those peoples both aliased?

Name: Anonymous 2009-06-17 17:47

>>7
you're gay and cats like milk

Name: Anonymous 2009-06-17 17:54

Sagefault (thread bumped.)

Name: Anonymous 2009-06-17 19:26

REP MOVSB

Name: Anonymous 2009-06-17 19:35

>>8
My cat is homophobic and lactose intolerant.

Name: Anonymous 2009-06-17 20:12

>>11
that sucks I guess

Name: Anonymous 2009-06-17 20:57

>>10
good implementations use
REP MOVSD to move in groups of dwords, then do an "and _rest_reg,3" (mod 4) to calculate the remaining size, and rep movsb the rest if any.

Name: Anonymous 2009-06-17 21:26

Name: C-man! 2009-06-18 0:18

/* Lets compare them! */

void * __cdecl memmove (
        void * dst,
        const void * src,
        size_t count
        )
{
        void * ret = dst;

#if defined (_M_IA64)
        {
        extern void RtlMoveMemory( void *, const void *, size_t count );

        RtlMoveMemory( dst, src, count );
        }
#else  /* defined (_M_IA64) */
        if (dst <= src || (char *)dst >= ((char *)src + count)) {
                /*
                 * Non-Overlapping Buffers
                 * copy from lower addresses to higher addresses
                 */
                while (count--) {
                        *(char *)dst = *(char *)src;
                        dst = (char *)dst + 1;
                        src = (char *)src + 1;
                }
        }
        else {
                /*
                 * Overlapping Buffers
                 * copy from higher addresses to lower addresses
                 */
                dst = (char *)dst + count - 1;
                src = (char *)src + count - 1;

                while (count--) {
                        *(char *)dst = *(char *)src;
                        dst = (char *)dst - 1;
                        src = (char *)src - 1;
                }
        }
#endif  /* defined (_M_IA64) */

        return(ret);
}


/**************************************************/



void * __cdecl memcpy (
        void * dst,
        const void * src,
        size_t count
        )
{
        void * ret = dst;

#if defined (_M_IA64)
        {
        extern void RtlMoveMemory( void *, const void *, size_t count );

        RtlMoveMemory( dst, src, count );
        }
#else  /* defined (_M_IA64) */
        /*
         * copy from lower addresses to higher addresses
         */
        while (count--) {
                *(char *)dst = *(char *)src;
                dst = (char *)dst + 1;
                src = (char *)src + 1;
        }
#endif  /* defined (_M_IA64) */

        return(ret);
}

Name: Anonymous 2009-06-18 3:27

>>13
Actually, the best results seem to be obtained with REP MOVSB followed by MOVSW if(count&2), and then MOVSB if(count&1).

Name: Anonymous 2009-06-18 14:02

>>13
Enjoy your unaligned access penalties.

Name: Anonymous 2009-06-18 14:53

>>17
I will along with my job

Name: Anonymous 2009-06-18 15:59

>>5
>Their both aliased to bcopy
Whose?
"both" belonging to who?
Your sentence is incomplete.

Name: Anonymous 2009-06-18 16:23

>>19
I am sentence is incomplete?  Maybe you should learn English buddy.

Name: ​​​​​​​​​​ 2010-10-22 12:58

Name: Anonymous 2013-08-31 17:49


 my god this is bugged as fuck

Name: Anonymous 2013-08-31 19:20


Finally, I have beaten all the Miracle Party Plus dungeons (without counting the 99F version you get after beating some of the hard ones).

Don't change these.
Name: Email:
Entire Thread Thread List