From a22ba2f1595b36b36556a9e29cf4698eb03c70d4 Mon Sep 17 00:00:00 2001 From: Oxy Date: Thu, 8 Jun 2006 06:57:46 +0000 Subject: [PATCH] several memory leaks and potential reasons for a crash removed (thanks to loigu) git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@13 119443c7-1b9e-41f8-b6fc-b9c35fce742c --- libupnp/upnp/src/api/upnpapi.c | 68 ++++++++++++++++++++-------------- libupnp/upnp/src/inc/upnpapi.h | 2 +- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/libupnp/upnp/src/api/upnpapi.c b/libupnp/upnp/src/api/upnpapi.c index 59f57eb..fa1ea8b 100644 --- a/libupnp/upnp/src/api/upnpapi.c +++ b/libupnp/upnp/src/api/upnpapi.c @@ -4213,33 +4213,6 @@ UpnpSetContentLength( IN UpnpClient_Handle Hnd, IN int contentLength /** Permissible content length */ ) -{ - return UpnpSetMaxContentLength (contentLength); -} - -/************************************************************************** - * Function: UpnpSetMaxContentLength - * - * Parameters: - * IN int contentLength: The maximum size to be set - * - * Description: - * Sets the maximum content-length that the SDK will process on an - * incoming SOAP requests or responses. This API allows devices that have - * memory constraints to exhibit consistent behaviour if the size of the - * incoming SOAP message exceeds the memory that device can allocate. - * The default maximum content-length is {\tt DEFAULT_SOAP_CONTENT_LENGTH} - * = 16K bytes. - * - * Return Values: int - * UPNP_E_SUCCESS: The operation completed successfully. - * - ***************************************************************************/ -int -UpnpSetMaxContentLength ( - IN size_t contentLength - /** Permissible content length, in bytes */ - ) { int errCode = UPNP_E_SUCCESS; struct Handle_Info *HInfo = NULL; @@ -4273,4 +4246,45 @@ UpnpSetMaxContentLength ( } + +/************************************************************************** + * Function: UpnpSetMaxContentLength + * + * Parameters: + * IN int contentLength: The maximum size to be set + * + * Description: + * Sets the maximum content-length that the SDK will process on an + * incoming SOAP requests or responses. This API allows devices that have + * memory constraints to exhibit consistent behaviour if the size of the + * incoming SOAP message exceeds the memory that device can allocate. + * The default maximum content-length is {\tt DEFAULT_SOAP_CONTENT_LENGTH} + * = 16K bytes. + * + * Return Values: int + * UPNP_E_SUCCESS: The operation completed successfully. + * + ***************************************************************************/ +int +UpnpSetMaxContentLength ( + IN size_t contentLength + /** Permissible content length, in bytes */ + ) +{ + int errCode = UPNP_E_SUCCESS; + + do { + if( UpnpSdkInit != 1 ) { + errCode = UPNP_E_FINISH; + break; + } + + g_maxContentLength = contentLength; + + } while( 0 ); + + return errCode; + +} + /*********************** END OF FILE upnpapi.c :) ************************/ diff --git a/libupnp/upnp/src/inc/upnpapi.h b/libupnp/upnp/src/inc/upnpapi.h index 74293ad..a1ef4e6 100644 --- a/libupnp/upnp/src/inc/upnpapi.h +++ b/libupnp/upnp/src/inc/upnpapi.h @@ -57,7 +57,7 @@ #define DEFAULT_SOAP_CONTENT_LENGTH 16000 #define MAX_SOAP_CONTENT_LENGTH 32000 -extern int g_maxContentLength; +extern size_t g_maxContentLength; // 30-second timeout #define UPNP_TIMEOUT 30