mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
Changed to use NdbAutoPtr instead of explicit free() calls
as suggested by Jonas (still Bug #17582)
This commit is contained in:
parent
17bc390ac5
commit
afca876979
1 changed files with 3 additions and 9 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <mgmapi.h>
|
||||
#include <mgmapi_configuration.hpp>
|
||||
#include <ConfigInfo.hpp>
|
||||
#include <NdbAutoPtr.hpp>
|
||||
|
||||
static int g_verbose = 0;
|
||||
static int try_reconnect = 3;
|
||||
|
@ -381,7 +382,6 @@ HostMatch::eval(const Iter& iter)
|
|||
{
|
||||
struct hostent *h1, *h2, copy1;
|
||||
char *addr1;
|
||||
int stat;
|
||||
|
||||
h1 = gethostbyname(m_value.c_str());
|
||||
if (h1 == NULL) {
|
||||
|
@ -392,30 +392,24 @@ HostMatch::eval(const Iter& iter)
|
|||
// so we need to copy the results before doing the next call
|
||||
memcpy(©1, h1, sizeof(struct hostent));
|
||||
addr1 = (char *)malloc(copy1.h_length);
|
||||
NdbAutoPtr<char> tmp_aptr(addr1);
|
||||
memcpy(addr1, h1->h_addr, copy1.h_length);
|
||||
|
||||
h2 = gethostbyname(valc);
|
||||
if (h2 == NULL) {
|
||||
free(addr1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (copy1.h_addrtype != h2->h_addrtype) {
|
||||
free(addr1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (copy1.h_length != h2->h_length)
|
||||
{
|
||||
free(addr1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
stat = memcmp(addr1, h2->h_addr, copy1.h_length);
|
||||
|
||||
free(addr1);
|
||||
|
||||
return (stat == 0);
|
||||
return 0 == memcmp(addr1, h2->h_addr, copy1.h_length);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue