* 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.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@566 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2010-08-21 21:10:50 +00:00
parent ce0d2833a3
commit 1605744278
3 changed files with 64 additions and 70 deletions

View File

@ -2,6 +2,11 @@
Version 1.6.7
*******************************************************************************
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* 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 <mroberto(at)users.sourceforge.net>
* New internal buffer added to store global/ula IPV6 address.
* Macros to test whether an IPV6 address is global or ula.

View File

@ -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;

View File

@ -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);