diff --git a/ChangeLog b/ChangeLog index 05f4504..b50a28e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ Version 1.6.7 ******************************************************************************* +2010-08-21 Marcelo Jimenez + * InitHandleList() has never been implemented, I guess no one has ever + called it, so remove it. + * GetFreeHandle() and FreeHandle() are now static as they should. + 2010-08-21 Marcelo Jimenez * New internal buffer added to store global/ula IPV6 address. * Macros to test whether an IPV6 address is global or ula. diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index be0092c..fd9f006 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -658,6 +658,65 @@ char *UpnpGetServerUlaGuaIp6Address(void) return gIF_IPV6_ULA_GUA; } + +/*! + * \brief Get a free handle. + * + * \return On success, an integer greater than zero or UPNP_E_OUTOF_HANDLE on + * failure. + */ +static int GetFreeHandle() +{ + /* Handle 0 is not used as NULL translates to 0 when passed as a handle */ + int i = 1; + + while (i < NUM_HANDLE && HandleTable[i] != NULL) { + ++i; + } + + if (i == NUM_HANDLE) { + return UPNP_E_OUTOF_HANDLE; + } else { + return i; + } +} + + +/*! + * \brief Free handle. + * + * \return UPNP_E_SUCCESS if successful or UPNP_E_INVALID_HANDLE if not + */ +static int FreeHandle( + /*! [in] Handle index. */ + int Upnp_Handle) +{ + int ret = UPNP_E_INVALID_HANDLE; + + UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, + "FreeHandle: entering, Handle is %d\n", Upnp_Handle); + + if (Upnp_Handle < 1 || Upnp_Handle >= NUM_HANDLE) { + UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__, + "FreeHandle: Handle %d is out of range\n", + Upnp_Handle); + } else if (HandleTable[Upnp_Handle] == NULL) { + UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__, + "FreeHandle: HandleTable[%d] is NULL\n", + Upnp_Handle); + } else { + free( HandleTable[Upnp_Handle] ); + HandleTable[Upnp_Handle] = NULL; + ret = UPNP_E_SUCCESS; + } + + UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, + "FreeHandle: exiting, ret = %d.\n", ret); + + return ret; +} + + #ifdef INCLUDE_DEVICE_APIS int UpnpRegisterRootDevice( const char *DescUrl, @@ -3353,23 +3412,6 @@ Upnp_FunPtr GetCallBackFn(UpnpClient_Handle Hnd) } -int GetFreeHandle() -{ - /* Handle 0 is not used as NULL translates to 0 when passed as a handle */ - int i = 1; - - while (i < NUM_HANDLE && HandleTable[i] != NULL) { - ++i; - } - - if (i == NUM_HANDLE) { - return UPNP_E_OUTOF_HANDLE; - } else { - return i; - } -} - - /* Assumes at most one client */ Upnp_Handle_Type GetClientHandleInfo( UpnpClient_Handle *client_handle_out, @@ -3445,34 +3487,6 @@ Upnp_Handle_Type GetHandleInfo( } -int FreeHandle(int Upnp_Handle) -{ - int ret = UPNP_E_INVALID_HANDLE; - - UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, - "FreeHandle: entering, Handle is %d\n", Upnp_Handle); - - if (Upnp_Handle < 1 || Upnp_Handle >= NUM_HANDLE) { - UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__, - "FreeHandle: Handle %d is out of range\n", - Upnp_Handle); - } else if (HandleTable[Upnp_Handle] == NULL) { - UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__, - "FreeHandle: HandleTable[%d] is NULL\n", - Upnp_Handle); - } else { - free( HandleTable[Upnp_Handle] ); - HandleTable[Upnp_Handle] = NULL; - ret = UPNP_E_SUCCESS; - } - - UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, - "FreeHandle: exiting, ret = %d.\n", ret); - - return ret; -} - - int PrintHandleInfo(UpnpClient_Handle Hnd) { struct Handle_Info * HndInfo; diff --git a/upnp/src/inc/upnpapi.h b/upnp/src/inc/upnpapi.h index 22daa73..06486f5 100644 --- a/upnp/src/inc/upnpapi.h +++ b/upnp/src/inc/upnpapi.h @@ -272,31 +272,6 @@ int UpnpGetIfInfo( const char *IfName); -/*! - * \brief Initialize handle table. - */ -void InitHandleList(); - - -/*! - * \brief Get a free handle. - * - * \return On success, an integer greater than zero or UPNP_E_OUTOF_HANDLE on - * failure. - */ -int GetFreeHandle(); - - -/*! - * \brief Free handle. - * - * \return UPNP_E_SUCCESS if successful or UPNP_E_INVALID_HANDLE if not - */ -int FreeHandle( - /*! [in] Handle index. */ - int Handle); - - void UpnpThreadDistribution(struct UpnpNonblockParam * Param);