On Sun, 19 Jul 2009, [email protected] wrote:

Hi,

> 2009-07-20 00:48 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
>    * include/Makefile
>    + include/hbapinet.h
>    * source/rtl/hbinet.c
>      + Moved some basic declarations to new API header,
>        mainly to export hb_select[Read|Write]*() functions.
>        We will also need such header in the future when
>        we implement C level socket/networking API. Current
>        solution is quite messy since the header has to
>        pull Windows headers which may not be friendly with
>        all usages/include order.
>    * source/rtl/hbinet.c
>      * HB_SOCKET_STRUCT renamed to HB_SOCKET.
>      + Added PHB_SOCKET type.
>      + Added hb_selectReadFD(), hb_selectWriteFD() which
>        are similar to hb_selectReadSocket() and
>        hb_selectWriteSocket() but expect raw FD plus explicit
>        timeout values.
>        These function names and solutions are tentative
>        to solve SSL integration with Harbour, and hopefully
>        in the future we will have a clean net API, the current
>        one is very messy.

The above modification made internal inet structure public.
I do not remember that we ever decide that it's official Harbour
inet API.
I'm working on new socket library but it does not have any public
HB_SOCKET and I do not plan to introduce anything like that.
Now I do not know if it's sense to continue this job.
Can we agree what is our goal for Harbour socket API?

>    * source/vm/itemapi.c
>      ! hb_itemPutCPtr(), hb_itemPutCLPtr() fixed to put empty
>        string to item if szText is NULL and length is non-zero,
>        instead of trying to free NULL pointer causing internal
>        error.

It was never legal to call these functions with NULL pointers. We can
define such functionality as legal but in such case your modifications
have to be changed:
   if( ulLen == 0 || szText == NULL )
in hb_itemPutCPtr() is redundant and:
   if( ulLen == 0 )
is enough and in hb_itemPutCLPtr():
   pItem->item.asString.length = ulLen;
   if( ulLen == 0 || szText == NULL )
   {
      pItem->item.asString.allocated = 0;
      pItem->item.asString.value     = ( char * ) "";
      if( szText )
         hb_xfree( szText );
   }
have to be fixed to set valid string size because no corrupted items
are created when szText is NULL and ulLen > 0 so it should be:
   if( szText == NULL )
      ulLen = 0;
   pItem->item.asString.length = ulLen;
   if( ulLen == 0 )
   {
      pItem->item.asString.allocated = 0;
      pItem->item.asString.value     = ( char * ) "";
      if( szText )
         hb_xfree( szText );
   }
Anyhow I do not find such modification as good idea. IMHO passing
NULL pointers to hb_itemPutC[L]Ptr() should be forbidden because
usually it's result of some mistake in calling code so previous
code which caused GPF and allow to easy find and fix potential problem
was better but it's only my personal preference so I can accept also
extended hb_itemPutC[L]Ptr() behavior though accepting code like:
   hb_itemPutCLPtr( pItem, NULL, 100 );
looks strange for me.

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to