c - memcopy for embedded system I just implemented my memcpy function without any previous lookup.
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

void * copy ( void * destination, const void * source, size_t num )
{
    if ((destination != NULL) &amp;&amp; (source != NULL))
    {
        unsigned int *dst = destination;
        const unsigned int *src = source;
        
        unsigned int blocks = num/sizeof(unsigned int);
        unsigned int left = num%sizeof(unsigned int);
        
        while(blocks--){
            *dst++ = *src++;
        }
        
        if (left){
            unsigned char *cdst = (unsigned char *)dst;
            const unsigned char *csrc = (const unsigned char *)src;
            
            while(left--)
                *cdst++ = *csrc++;
        }
        
    }
    
    return destination;
}

When looking at other memcpy implementations I find some differences:

unaligned address not handled
use of long instead unsigned int

Now what I didn't understand is point number 2. As far I know int will always be CPU WORD size i.e for 16bit it will be 2bytes and 32bit it will be 4bytes. But for long it must be 32bit minimum.
Alignment
unsigned int *dst = destination; fails when destination is not aligned for unsigned.  Same for src. (OP seems be somewhat aware of this given &quot;unaligned address not handled&quot;)
Aliasing
Possible strict aliasing violation.  See What is the strict aliasing rule?
Fails when buffers overlap
Without restrict, buffer may overlap and code does not well handle overlaps in both directions.
Recommend to use restrict like memcpy().
void *memcpy(void * restrict s1, const void * restrict s2, size_t n);

CPU WORD size
&quot;I know int will always be CPU WORD size&quot; discounts 8-bits CPUs (common in embedded code).  On those, an int is at least 16-bit, not 8-bit.
The low-level copy size is typically related to the CPU word size, but much of this is implementation dependent.
Usually unsigned is good or best, but one would need to profile the implementation to know for sure.
Minor: Unneeded code
Test of left not unneeded as later while(left--) does the job.
// if (left)

NULL Testing
Common to not test for null-ness.  memcpy() is not require to do so, nor is it required to not test NULL.  What should be done depends on overall coding goals, so it is up to you.