lkml.org 
[lkml]   [1998]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: faster strcpy()
    Date

    -----Original Message-----
    From: Anthony Barbachan <barbacha@Trill.cis.fordham.edu>
    To: Meelis Roos <mroos@tartu.cyber.ee>; linux-kernel@vger.rutgers.edu
    <linux-kernel@vger.rutgers.edu>
    Date: Saturday, April 25, 1998 9:16 PM
    Subject: Re: faster strcpy()


    >
    >-----Original Message-----
    >From: Meelis Roos <mroos@tartu.cyber.ee>
    >To: linux-kernel@vger.rutgers.edu <linux-kernel@vger.rutgers.edu>
    >Date: Friday, April 24, 1998 4:44 AM
    >Subject: Re: faster strcpy()
    >
    >
    >>> #define strcpy(a,b) (char *)memcpy(a,b,strlen(b))
    >>
    >>As I understand, it first finds the length of b and then in second pass
    >>it copies the data. It would be even faster if we could do it with 1 pass
    >>(but fast like memcpy).
    >>
    >
    >
    >How about:
    >
    >inline char* strcpy(char* dest, char* src)
    >{
    > while((*dest = *src) != '\0')
    > {
    > dest++;
    > src++;
    > }
    >}
    >
    >>Meelis Roos (mroos@tartu.cyber.ee)
    >>
    >>
    >>-
    >>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    >>the body of a message to majordomo@vger.rutgers.edu
    >>
    >
    >

    Correction:

    inline char* strcpy(char* dest, char* src)
    {
    char* origdest = dest;

    while((*dest = *src) != '\0')
    {
    dest++;
    src++;
    }

    return origdest;
    }




    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu

    \
     
     \ /
      Last update: 2005-03-22 13:42    [W:0.022 / U:118.684 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site