Re: C chars_ptr STORAGE_ERROR in Imported function



Kim Rostgaard Christensen wrote:
Hello there

I am in progress of binding the pcap c library to ada, it is a part of a
school project. And for that i need a funtion that modifies a parameter to a function like so:

char *pcap_lookupdev(char *);

....

Do I need to declare the buffer and then then pass its c pointer to the function?

That is certainly my interpretation of the "man" text:

char *pcap_lookupdev(char *errbuf)

pcap_lookupdev() returns a pointer to a network device
suitable for use with pcap_open_live() and pcap_lookupnet().
If there is an error, NULL is returned and errbuf is filled
in with an appropriate error message.

There is no hint that pcap_lookupdev() itself allocates the errbuf; it just puts something in the caller-provided errbuf. And no doubt places a NUL terminator after the message.

HTH

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
.



Relevant Pages

  • Re: C chars_ptr STORAGE_ERROR in Imported function
    ... Since you have left Errbuf uninitialized, this may be a lot less than 256 characters, so the errors are probably due to buffer overflow somewhere in the pcap library where it tries to put an error message into the char_array that Errrbuf_Ptr points to, but this char_array is too small. ... If you want to continue with New_Char_Array, you should initialize Errbuf to contain a 256-character string: ...
    (comp.lang.ada)
  • Re: C chars_ptr STORAGE_ERROR in Imported function
    ... school project. ... pcap_lookupdevreturns a pointer to a network device ... NULL is returned and errbuf is filled ... in with an appropriate error message. ...
    (comp.lang.ada)
  • Re: C chars_ptr STORAGE_ERROR in Imported function
    ... Niklas Holsti wrote: ... a chars_ptr that points to Errbuf itself, without allocating another char_array, so there is no need to Free anything. ... This also needs a change in the declaration of Errbuf: ...
    (comp.lang.ada)