Port driver memory free

casper2000a <>
Wed Mar 23 03:32:46 CET 2005


Thanks Raimo and Vance for you generous advice!

- Eranga



Quoting Raimo Niskanen : > Quoting Raimo Niskanen :

> Rather correct...
> 
> driver_entry->call() should return memory allocated with 
> driver_alloc(), and the contents should be in external term format
> as from the ei_* functions. You do not have to allocate memory
> if the return value fits in the preallocated buffer.
> 
> driver_entry->control() should return memory allocated with
> driver_alloc(), and the contents is interpreted as a list of
> integers [0..255]. You do not have to allocate memory if the
> return value fits in the preallocated buffer. 
> 
> If you set the PORT_CONTROL_FLAG_BINARY flag, 
> driver_entry->control() should instead return a binary allocated 
> with driver_alloc_binary() and it is interpreted as a binary (!), 
> except if you (do not allocate a binary and) set the return buffer 
> to NULL which is interpreted as an empty list (allowed from R10B).
> The preallocated return buffer can not be used.
> 
> Note that you do not have to encode the result value using ei_*
> functions when you use driver_entry->control(). The encoding
> of the binary (or list) is entirely up to the driver and its
> calling erlang code. It is probably faster to encode the data
> in a suitable way of your own.
> 
> 
> 
>  (Casper) writes:
> 
> > Only difference is call use external term format, so need to use
> > driver_alloc, but control doesn\'t so use driver_alloc_binary, Correct?
> > 
> > - Eranga
> > 
> > 
> > -----Original Message-----
> > From: 
> > [mailto:] On Behalf Of Casper
> > Sent: Tuesday, March 22, 2005 5:03 PM
> > To: \'Vance Shipley\'
> > Cc: ; 
> > Subject: RE: Port driver memory free
> > 
> > Vance,
> > 
> > Regarding port_call and port_control, I think both can use ei library
> > functions to encode/decode terms, correct? If not, please advice how
> they\'ve
> > being done.
> > 
> > I am sorry if I did something offending. But to my understanding the code
> I
> > published only carries a very generic Erlang-C port code. Even on the
> Erlang
> > manuals or samples, the same method is shown.
> > 
> > Thanks!
> > - Eranga
> > 
> > 
> > 
> > 
> > -----Original Message-----
> > From: Vance Shipley [mailto:] 
> > Sent: Tuesday, March 22, 2005 10:44 AM
> > To: 
> > Cc: ; 
> > Subject: Re: Port driver memory free
> > 
> > Eranga,
> > 
> > Your problem is that you have copied my (copyrighted) code written
> > for use with erlang:port_call/3 and reused it with erlang:port_control/3.
> > The difference between the two is that port_call/3 uses the external 
> > term format as encoded by the ei library while port_control/3 uses the
> > driver binary format.
> > 
> > -Vance
> > 
> > 
> > Motivity Telecom Inc.
> > +1 519 240 3684
> > 
> > 
> > 
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> 

--------------This mail sent through OmniBIS.com--------------




More information about the erlang-questions mailing list