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

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 15 May 2008 14:49:26 -0400
"Bob McConnell" <rvm@CBORD.com> wrote:

> >>> My code so far:
> >>>
> >>> ----------------- tear along dotted line -----------------
> >>>  tapFD = open ("/dev/tap0", O_RDWR);
> >>>  if (tapFD < 0) {
> >>>    fprintf (stderr, "Failed to open /dev/tap0: %d.\n", tapFD);
> >>>    exit (2);
> >>>  }
> >>>
> >>>  fprintf (stderr, "Successfully opened /dev/tap0.\n");
> >>>
> >>>  unsigned char * buffer = (unsigned char*)malloc(1514);
> >>>  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?




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