summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-16 16:36:54 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-01-16 21:03:22 +0100
commit5b670b7ab467223d77d9101cb192021cdf71021f (patch)
tree52af303c4bdc2aab135a3e13b8b002977f2eeaed /sal
parent9bc56a8b61c276a4fa08db3e45b78122273feb2b (diff)
Avoid unnecessary string copying in osl_getUserName
Change-Id: I00a4b6aef307621b1607abbe75b3a64e6f8fb40a Reviewed-on: https://gerrit.libreoffice.org/66464 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/socket.cxx33
1 files changed, 6 insertions, 27 deletions
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 0765daaef2e7..454ff463d70f 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -278,9 +278,6 @@ static oslSocketAddr osl_psz_resolveHostname (
static sal_Int32 osl_psz_getServicePort (
const sal_Char* pszServicename, const sal_Char* pszProtocol);
-static oslSocketResult osl_psz_getHostnameOfSocketAddr (
- oslSocketAddr Addr, sal_Char *pBuffer, sal_uInt32 BufferSize);
-
static oslSocketResult osl_psz_getDottedInetAddrOfSocketAddr (
oslSocketAddr Addr, sal_Char *pBuffer, sal_uInt32 BufferSize);
@@ -1097,36 +1094,18 @@ sal_Bool SAL_CALL osl_setInetPortOfSocketAddr(oslSocketAddr pAddr, sal_Int32 Por
oslSocketResult SAL_CALL osl_getHostnameOfSocketAddr(oslSocketAddr Addr, rtl_uString **ustrHostname)
{
- oslSocketResult Result;
- sal_Char pszHostname[1024];
+ oslHostAddr pHostAddr= osl_createHostAddrByAddr(Addr);
- pszHostname[0] = '\0';
-
- Result = osl_psz_getHostnameOfSocketAddr(Addr,pszHostname,sizeof(pszHostname));
- if (Result == osl_Socket_Ok)
+ if (!pHostAddr)
{
- rtl_uString_newFromAscii(ustrHostname,pszHostname);
+ return osl_Socket_Error;
}
- return Result;
-}
+ rtl_uString_newFromAscii(ustrHostname,pHostAddr->pHostName);
-oslSocketResult osl_psz_getHostnameOfSocketAddr(oslSocketAddr pAddr,
- sal_Char *pBuffer, sal_uInt32 BufferSize)
-{
- oslHostAddr pHostAddr= osl_createHostAddrByAddr(pAddr);
-
- if (pHostAddr)
- {
- strncpy(pBuffer, pHostAddr->pHostName, BufferSize);
- pBuffer[BufferSize - 1] = '\0';
-
- osl_destroyHostAddr(pHostAddr);
+ osl_destroyHostAddr(pHostAddr);
- return osl_Socket_Ok;
- }
-
- return osl_Socket_Error;
+ return osl_Socket_Ok;
}
oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr(oslSocketAddr Addr, rtl_uString **ustrDottedInetAddr)