Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/generic/src/memstr.c

    r45f7449 rb31f735  
    3030#include <typedefs.h>
    3131
    32 /** Move memory block without overlapping.
     32/** Copy block of memory.
    3333 *
    34  * Copy cnt bytes from src address to dst address. The source
    35  * and destination memory areas cannot overlap.
     34 * Copy cnt bytes from src address to dst address.The source and destination
     35 * memory areas cannot overlap.
    3636 *
    37  * @param dst Destination address to copy to.
    38  * @param src Source address to copy from.
    39  * @param cnt Number of bytes to copy.
     37 * @param src           Source address to copy from.
     38 * @param dst           Destination address to copy to.
     39 * @param cnt           Number of bytes to copy.
    4040 *
    41  * @return Destination address.
    42  *
     41 * @return              Destination address.
    4342 */
    4443void *memcpy(void *dst, const void *src, size_t cnt)
    4544{
    46         uint8_t *dp = (uint8_t *) dst;
    47         const uint8_t *sp = (uint8_t *) src;
    48        
    49         while (cnt-- != 0)
    50                 *dp++ = *sp++;
    51        
    52         return dst;
    53 }
     45        size_t i;
    5446
    55 /** Fill block of memory.
    56  *
    57  * Fill cnt bytes at dst address with the value val.
    58  *
    59  * @param dst Destination address to fill.
    60  * @param val Value to fill.
    61  * @param cnt Number of bytes to fill.
    62  *
    63  * @return Destination address.
    64  *
    65  */
    66 void *memset(void *dst, int val, size_t cnt)
    67 {
    68         uint8_t *dp = (uint8_t *) dst;
    69        
    70         while (cnt-- != 0)
    71                 *dp++ = val;
    72        
     47        for (i = 0; i < cnt; i++)
     48                ((uint8_t *) dst)[i] = ((uint8_t *) src)[i];
     49
    7350        return dst;
    7451}
Note: See TracChangeset for help on using the changeset viewer.