From owner-freebsd-questions@FreeBSD.ORG Fri May 16 13:25:09 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B0AC106567D for ; Fri, 16 May 2008 13:25:09 +0000 (UTC) (envelope-from freebsd-questions@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id 231278FC0A for ; Fri, 16 May 2008 13:25:09 +0000 (UTC) (envelope-from freebsd-questions@m.gmane.org) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1Jwzvi-0002m3-My for freebsd-questions@freebsd.org; Fri, 16 May 2008 13:25:02 +0000 Received: from adsl-75-27-227-39.dsl.wchtks.sbcglobal.net ([75.27.227.39]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 May 2008 13:25:02 +0000 Received: from srandall52 by adsl-75-27-227-39.dsl.wchtks.sbcglobal.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 May 2008 13:25:02 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-questions@freebsd.org From: Steve Randall Date: Fri, 16 May 2008 08:19:03 -0500 Lines: 31 Message-ID: <20080516081903.333b342d@locust> References: <20080514234101.P2316@wojtek.tensor.gdynia.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: adsl-75-27-227-39.dsl.wchtks.sbcglobal.net In-Reply-To: X-Newsreader: Claws Mail 3.4.0 (GTK+ 2.12.9; i386-portbld-freebsd7.0) Sender: news Subject: Re: Unable to talk to tap(4) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 May 2008 13:25:09 -0000 On Thu, 15 May 2008 14:49:26 -0400 "Bob McConnell" 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?