9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Binit and Bterm
@ 2006-10-05 19:32 Joel “chesky” Salomon
  2006-10-05 20:26 ` Tim Wiess
  0 siblings, 1 reply; 12+ messages in thread
From: Joel “chesky” Salomon @ 2006-10-05 19:32 UTC (permalink / raw)
  To: 9fans

I’ve got a function in the Brain-Dead SHell™ that I’m writing for
homework that looks like this:
	Biobuf in;

	void bdsh(int f) {
		Binit(&in, f, OREAD); yyparse(); Bterm(&in);
	}
This function gets called for each file named in argv[] after main()
open(2)s it.

My question is: is the call Bterm necessary, or will Binit
reinitialize the global Biobuf correctly on its own—or am I courting
trouble some other way?  The man page for bio(2) is a bit vauge on
reusing Biobufs.

--Joel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 19:32 [9fans] Binit and Bterm Joel “chesky” Salomon
@ 2006-10-05 20:26 ` Tim Wiess
  2006-10-05 20:33   ` Joel “chesky” Salomon
  0 siblings, 1 reply; 12+ messages in thread
From: Tim Wiess @ 2006-10-05 20:26 UTC (permalink / raw)
  To: 9fans; +Cc: JoelCSalomon

    since you are just doing reads then no i don't believe
    the Bterm is necessary.


> I’ve got a function in the Brain-Dead SHell™ that I’m writing for
> homework that looks like this:
> 	Biobuf in;
> 
> 	void bdsh(int f) {
> 		Binit(&in, f, OREAD); yyparse(); Bterm(&in);
> 	}
> This function gets called for each file named in argv[] after main()
> open(2)s it.
> 
> My question is: is the call Bterm necessary, or will Binit
> reinitialize the global Biobuf correctly on its own—or am I courting
> trouble some other way?  The man page for bio(2) is a bit vauge on
> reusing Biobufs.
> 
> --Joel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 20:26 ` Tim Wiess
@ 2006-10-05 20:33   ` Joel “chesky” Salomon
  2006-10-05 20:43     ` Russ Cox
                       ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Joel “chesky” Salomon @ 2006-10-05 20:33 UTC (permalink / raw)
  To: 9fans

> since you are just doing reads then no i don't believe
> the Bterm is necessary.

So will Binit properly reinitialize its argument, reusing the buffers
rather than allocating new ones and leaking the old?

--Joel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 20:33   ` Joel “chesky” Salomon
@ 2006-10-05 20:43     ` Russ Cox
  2006-10-05 20:47     ` Charles Forsyth
  2006-10-05 21:42     ` Tim Wiess
  2 siblings, 0 replies; 12+ messages in thread
From: Russ Cox @ 2006-10-05 20:43 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

The only buffer is on the stack inside the Biobuf.
There is no dynamic allocation in this case.

Russ


On 10/5/06, Joel "chesky" Salomon <JoelCSalomon@gmail.com> wrote:
> > since you are just doing reads then no i don't believe
> > the Bterm is necessary.
>
> So will Binit properly reinitialize its argument, reusing the buffers
> rather than allocating new ones and leaking the old?
>
> --Joel
>
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 20:33   ` Joel “chesky” Salomon
  2006-10-05 20:43     ` Russ Cox
@ 2006-10-05 20:47     ` Charles Forsyth
  2006-10-05 21:00       ` Joel “chesky” Salomon
  2006-10-05 21:42     ` Tim Wiess
  2 siblings, 1 reply; 12+ messages in thread
From: Charles Forsyth @ 2006-10-05 20:47 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

according to /sys/src/libbio/binit.c, Binit doesn't
allocate buffers (that's done by Bopen), and Bterm
for a Biobuf initialised to OREAD by Binit doesn't do much.

i'd still call Bterm though, especially in these days of cut and paste

[-- Attachment #2: Type: message/rfc822, Size: 2472 bytes --]

From: Joel “chesky” Salomon <JoelCSalomon@Gmail.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Binit and Bterm
Date: Thu, 5 Oct 2006 16:33:32 -0400
Message-ID: <8eeb3016afcfba5a3719301de1824a5f@plan9.jp>

> since you are just doing reads then no i don't believe
> the Bterm is necessary.

So will Binit properly reinitialize its argument, reusing the buffers
rather than allocating new ones and leaking the old?

--Joel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 20:47     ` Charles Forsyth
@ 2006-10-05 21:00       ` Joel “chesky” Salomon
  2006-10-05 21:08         ` Charles Forsyth
  0 siblings, 1 reply; 12+ messages in thread
From: Joel “chesky” Salomon @ 2006-10-05 21:00 UTC (permalink / raw)
  To: 9fans

> i'd still call Bterm though, especially in these days of cut and paste

I think I’d rather have things break on cut-and-paste-ers. ☺

--Joel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 21:00       ` Joel “chesky” Salomon
@ 2006-10-05 21:08         ` Charles Forsyth
  2006-10-05 21:09           ` Joel “chesky” Salomon
  0 siblings, 1 reply; 12+ messages in thread
From: Charles Forsyth @ 2006-10-05 21:08 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 74 bytes --]

i suppose i don't see that problem in calling the function.
what is it?

[-- Attachment #2: Type: message/rfc822, Size: 2427 bytes --]

From: Joel “chesky” Salomon <JoelCSalomon@Gmail.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Binit and Bterm
Date: Thu, 5 Oct 2006 17:00:32 -0400
Message-ID: <96d9086fc9539edad73f1242fb629a9a@plan9.jp>

> i'd still call Bterm though, especially in these days of cut and paste

I think I’d rather have things break on cut-and-paste-ers. ☺

--Joel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 21:08         ` Charles Forsyth
@ 2006-10-05 21:09           ` Joel “chesky” Salomon
  2006-10-05 21:38             ` Martin Neubauer
  0 siblings, 1 reply; 12+ messages in thread
From: Joel “chesky” Salomon @ 2006-10-05 21:09 UTC (permalink / raw)
  To: 9fans

> > I think I’d rather have things break on cut-and-paste-ers. ☺
> 
> i suppose i don't see that problem in calling the function.
> what is it?

I’m actually leaving the Bterm in the code for clarity; I was just making a joke about leaving brittle code about so it can’t be copied without understanding it.

--Joel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 21:09           ` Joel “chesky” Salomon
@ 2006-10-05 21:38             ` Martin Neubauer
  2006-10-05 21:42               ` Charles Forsyth
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Neubauer @ 2006-10-05 21:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

* Joel âcheskyâ Salomon (JoelCSalomon@Gmail.com) wrote:
> I'm actually leaving the Bterm in the code for clarity; I was just making
> a joke about leaving brittle code about so it can't be copied without
> understanding it.

It will anyway.

Martin


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 21:38             ` Martin Neubauer
@ 2006-10-05 21:42               ` Charles Forsyth
  0 siblings, 0 replies; 12+ messages in thread
From: Charles Forsyth @ 2006-10-05 21:42 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

yes, i was going to suggest that perhaps there should be a rich text
format  in plan 9 for source code storage allwoing subtle code to be tagged so
could not be edited without understanding it, or at least reading it,
but then i realised that i wouldn't then be able to edit code of my own.

[-- Attachment #2: Type: message/rfc822, Size: 3113 bytes --]

From: Martin Neubauer <m.ne@gmx.net>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Binit and Bterm
Date: Thu, 5 Oct 2006 23:38:09 +0200
Message-ID: <20061005213809.GA11079@shodan.homeunix.net>

* Joel âcheskyâ Salomon (JoelCSalomon@Gmail.com) wrote:
> I'm actually leaving the Bterm in the code for clarity; I was just making
> a joke about leaving brittle code about so it can't be copied without
> understanding it.

It will anyway.

Martin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
  2006-10-05 20:33   ` Joel “chesky” Salomon
  2006-10-05 20:43     ` Russ Cox
  2006-10-05 20:47     ` Charles Forsyth
@ 2006-10-05 21:42     ` Tim Wiess
  2 siblings, 0 replies; 12+ messages in thread
From: Tim Wiess @ 2006-10-05 21:42 UTC (permalink / raw)
  To: 9fans

> So will Binit properly reinitialize its argument, reusing the buffers
> rather than allocating new ones and leaking the old?

    yes the buffer will be reinitialized, but as Russ said, it is
    not dynamically allocated.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Binit and Bterm
       [not found] <000001c6e8b6$cbc14250$14aaa8c0@utelsystems.local>
@ 2006-10-06  6:03 ` "Nils O. Selåsdal"
  0 siblings, 0 replies; 12+ messages in thread
From: "Nils O. Selåsdal" @ 2006-10-06  6:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Joel “chesky” Salomon wrote:
> I’ve got a function in the Brain-Dead SHell™ that I’m writing for
> homework that looks like this:
> 	Biobuf in;
> 
> 	void bdsh(int f) {
> 		Binit(&in, f, OREAD); yyparse(); Bterm(&in);
> 	}
> This function gets called for each file named in argv[] after main()
> open(2)s it.
> 
> My question is: is the call Bterm necessary, or will Binit
> reinitialize the global Biobuf correctly on its own—or am I courting
> trouble some other way?  The man page for bio(2) is a bit vauge on
> reusing Biobufs.

What's one extra, correct, Bterm call among friends ?


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-10-06  6:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-05 19:32 [9fans] Binit and Bterm Joel “chesky” Salomon
2006-10-05 20:26 ` Tim Wiess
2006-10-05 20:33   ` Joel “chesky” Salomon
2006-10-05 20:43     ` Russ Cox
2006-10-05 20:47     ` Charles Forsyth
2006-10-05 21:00       ` Joel “chesky” Salomon
2006-10-05 21:08         ` Charles Forsyth
2006-10-05 21:09           ` Joel “chesky” Salomon
2006-10-05 21:38             ` Martin Neubauer
2006-10-05 21:42               ` Charles Forsyth
2006-10-05 21:42     ` Tim Wiess
     [not found] <000001c6e8b6$cbc14250$14aaa8c0@utelsystems.local>
2006-10-06  6:03 ` "Nils O. Selåsdal"

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).