[lkml]   [2000]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: malloc(1/0) ??
    On Mon, 6 Nov 2000, RAJESH BALAN wrote:

    > hi,
    > why does this program works. when executed, it doesnt
    > give a segmentation fault. when the program requests
    > memory, is a standard chunk is allocated irrespective
    > of the what the user specifies. please explain.
    > main()
    > {
    > char *s;
    > s = (char*)malloc(0);

    malloc(0) is bogus in this case. malloc(0) == free();

    > strcpy(s,"fffff");
    > printf("%s\n",s);
    > }
    > NOTE:
    > i know its a 'C' problem. but i wanted to know how
    > this works

    The most plausible reason is you're not crossing a page boundary, and you
    don't get a access violation.


    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 12:45    [W:0.019 / U:7.124 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site