[En-Nut-Discussion] Bug #1799374: NutRegisterCgi() Parameter 1

Thiago A. Corrêa thiago.correa at gmail.com
Tue Apr 1 20:28:42 CEST 2008


Hi,

It is true that you can not guarantee that the pointer will always
remain valid. The only safe thing to do would be to copy it, and waste
some memory. Doing that will hurt most of ethernut users that
intentionally or not are using NutCgiRegister with constant values
and, as a special case, are able to save a few bytes.

   I guess the most sensible thing is to document, in big letters,
that NutCgiRegister assumes the pointer will remain valid and perhaps
provide a NutCgiRegister2() which will copy the argument. It could
even be inline with a simple NutCgiRegister( strdup( arg1 ), arg2 )
call. Which would most likely mimic what we have today, that is, never
being able to free that memory, unless there is a way to unregister
Cgi's that I'm not aware of.

Kind Regards,
   Thiago A. Correa


On Tue, Apr 1, 2008 at 2:01 PM, Nathan Moore <nategoose at gmail.com> wrote:
> On Tue, Apr 1, 2008 at 12:51 PM, Alain M. <alainm at pobox.com> wrote:
>
>  > I don't understand something in what you say:
>  > 1) if you have a string that is NOT const and you pass it to a function
>  > that has a cont parameter, it is ok and no error messages
>  > 2) once a file is open, you will not use it's name anymore, so it can be
>  > discated anytime
>
>  NutCgiRegister isn't opening files.  It compares the *_file_name_ to http
>  GET requests later
>  when the http server is up.
>
>
>  >
>  >
>  > Alain
>  > BTW, the example bellow could crash because the second string is bigger
>  > than the first...
>  >
>  That wasn't the point of that example. Cursed variable width fonts throwing
>  off my length estimates.
>
>
>  Nathan
>
>
> _______________________________________________
>  http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>



More information about the En-Nut-Discussion mailing list