From owner-freebsd-hackers Wed Dec 6 13:28:51 2000 From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 6 13:28:48 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from homer.softweyr.com (mail.dobox.com [208.187.122.44]) by hub.freebsd.org (Postfix) with ESMTP id 3615837B400 for ; Wed, 6 Dec 2000 13:28:48 -0800 (PST) Received: from [127.0.0.1] (helo=softweyr.com ident=Fools trust ident!) by homer.softweyr.com with esmtp (Exim 3.16 #1) id 143mAB-0000LH-00; Wed, 06 Dec 2000 14:31:43 -0700 Sender: wes@FreeBSD.ORG Message-ID: <3A2EB03F.8D9105A8@softweyr.com> Date: Wed, 06 Dec 2000 14:31:43 -0700 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: "G. Adam Stanislav" Cc: Stephen McKay , hackers@FreeBSD.ORG Subject: Re: pipe References: <20001202085127.A301@int80h.org> <3A292D98.E655D755@softweyr.com> <20001203012841.B228@whizkidtech.net> <200012040256.eB42upH07905@dungeon.home> <20001205085645.A228@whizkidtech.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "G. Adam Stanislav" wrote: > > On Mon, Dec 04, 2000 at 12:56:51PM +1000, Stephen McKay wrote: > >Using pipes for temporary storage is still a crazy idea. Pipes can be > >smaller than 8K, depending on the flavour of Unix. > > It was just a thought, and it did not work. :) Other flavors of Unix > are not too important in this case: I'm writing a FreeBSD assembly > language tutorial. Though I do discuss portability issues in it. > I'm writing the tutorial, not because I'm the expert (I am, on assembly > language, but not on Unix system calls--yet), but because, in my > experience, it is the best way to learn. > > > Use malloc() instead. > > Unfortunately, that only works in C. :) You are, of course, wrong here. You can (and should) link your assembly programs with the C library -- half the power of UNIX is in the libraries. You can call all of the library functions just fine, as long as you under- stand the calling conventions. > I tried to figure out how to allocate memory, but, so far, was completely > unsuccessful. I studied the source for the C malloc, but did not understand > any of it. It uses something called mmap. I read the man page for mmap, > and was totally frustrated. It talks about mapping files into memory, > but I am not looking for files. It talks about passing an address to the > function. I don't get it... What address? I want it to allocate memory > for me and tell me its address. How am I supposed to know what address > is available??? If you pass it NULL as the address, mmap will select an address for you. If you just want to allocate some memory, mmap /dev/null MAP_PRIVATE. You need to read the man pages and the malloc code more carefully. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message