Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 May 2008 16:19:38 +0200 (CEST)
From:      Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>
To:        Steve Randall <srandall52@sbcglobal.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Unable to talk to tap(4)
Message-ID:  <20080516161816.M20005@wojtek.tensor.gdynia.pl>
In-Reply-To: <20080516081903.333b342d@locust>
References:  <FF8482A96323694490C194BABEAC24A002B83B78@Email.cbord.com> <20080514234101.P2316@wojtek.tensor.gdynia.pl> <FF8482A96323694490C194BABEAC24A002B841D1@Email.cbord.com> <20080516081903.333b342d@locust>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>>  unsigned char * buffer = (unsigned char*)malloc(1514);

is stdlib.h included (i'm asking for sure)?

>>>>>  if (buffer = NULL) {
>
>       if (buffer == NULL) {
>
>
>>>>>    fprintf (stderr, "No memory available.\n");
>>>>>    close (tapFD);
>>>>>    exit(3);
>>>>>  }
>>
>> When I replace the malloc with an automatic array, the
>> error goes away and I get the data I am looking for. i.e.:
>>
>>    unsigned char buffer[1514];
>>
>> So why can't I use malloc to create that buffer?

anyway not using malloc is good habit :) but it should work anyway.
try


buffer[0]=buffer[1513]=0;

to make sure page is actually allocated.

if this help - maybe tap driver is buggy.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080516161816.M20005>