lkml.org 
[lkml]   [2004]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: Some cleanup patches for: '...lvalues is deprecated'
    On Sat, Jul 03, 2004 at 09:39:24PM +0000, Joel Soete wrote:

    > Very interesting but well I am not enough fluent in C to understand this
    > fine detail :(
    > Can you explain me by an example (let say a long*) what would did "((char
    > *) buffer)++;" versus "buffer += sizeof(char);"
    > (Don't worry, if don't have time, I will perfectly understand and will
    > experiment by myself)

    Ok. Let's assume

    int *buffer;

    just for this example.

    ((char *) buffer)++;

    increments buffer by 1, while

    buffer += sizeof(char);

    increments buffer by 4, because an int* is always
    increased/decreased by multiples of sizeof(int).

    So

    buffer += 2;

    would increment the pointer by 8.

    Similarly for other pointer types.

    > >So just use
    > >
    > > buffer++;
    > >
    > >here, and the intent is then clear.
    > >
    > Yes ;)

    --
    Vojtech Pavlik
    SuSE Labs, SuSE CR
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 14:04    [W:0.021 / U:30.148 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site