nsiproxy: Switch memory allocations to malloc().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-10-01 15:07:05 +01:00 committed by Alexandre Julliard
parent 280999aee2
commit f6917badf1
4 changed files with 31 additions and 35 deletions

View File

@ -94,7 +94,6 @@
#include "ifdef.h"
#include "ipmib.h"
#include "netiodef.h"
#include "wine/heap.h"
#include "wine/nsi.h"
#include "wine/debug.h"
@ -933,12 +932,12 @@ static NTSTATUS ipv4_neighbour_enumerate_all( void *key_data, DWORD key_size, vo
if (sysctl( mib, ARRAY_SIZE(mib), NULL, &needed, NULL, 0 ) == -1) return STATUS_NOT_SUPPORTED;
buf = heap_alloc( needed );
buf = malloc( needed );
if (!buf) return STATUS_NO_MEMORY;
if (sysctl( mib, ARRAY_SIZE(mib), buf, &needed, NULL, 0 ) == -1)
{
heap_free( buf );
free( buf );
return STATUS_NOT_SUPPORTED;
}
@ -982,7 +981,7 @@ static NTSTATUS ipv4_neighbour_enumerate_all( void *key_data, DWORD key_size, vo
}
next += rtm->rtm_msglen;
}
heap_free( buf );
free( buf );
}
#else
FIXME( "not implemented\n" );
@ -1122,12 +1121,12 @@ static NTSTATUS ipv4_forward_enumerate_all( void *key_data, DWORD key_size, void
if (sysctl( mib, ARRAY_SIZE(mib), NULL, &needed, NULL, 0 ) < 0) return STATUS_NOT_SUPPORTED;
buf = heap_alloc( needed );
buf = malloc( needed );
if (!buf) return STATUS_NO_MEMORY;
if (sysctl( mib, 6, buf, &needed, NULL, 0 ) < 0)
{
heap_free( buf );
free( buf );
return STATUS_NOT_SUPPORTED;
}
@ -1225,7 +1224,7 @@ static NTSTATUS ipv4_forward_enumerate_all( void *key_data, DWORD key_size, void
}
num++;
}
HeapFree( GetProcessHeap (), 0, buf );
free( buf );
}
#else
FIXME( "not implemented\n" );

View File

@ -84,7 +84,6 @@
#include "ddk/wdm.h"
#include "wine/nsi.h"
#include "wine/list.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "nsiproxy_private.h"
@ -253,7 +252,7 @@ static WCHAR *strdupAtoW( const char *str )
if (!str) return ret;
len = MultiByteToWideChar( CP_UNIXCP, 0, str, -1, NULL, 0 );
ret = heap_alloc( len * sizeof(WCHAR) );
ret = malloc( len * sizeof(WCHAR) );
if (ret) MultiByteToWideChar( CP_UNIXCP, 0, str, -1, ret, len );
return ret;
}
@ -264,7 +263,7 @@ static struct if_entry *add_entry( DWORD index, char *name )
int name_len = strlen( name );
if (name_len >= IFNAMSIZ - 1) return NULL;
entry = heap_alloc( sizeof(*entry) );
entry = malloc( sizeof(*entry) );
if (!entry) return NULL;
entry->if_index = index;
@ -272,7 +271,7 @@ static struct if_entry *add_entry( DWORD index, char *name )
entry->if_name = strdupAtoW( name );
if (!entry->if_name)
{
heap_free( entry );
free( entry );
return NULL;
}
@ -385,7 +384,7 @@ static void ifinfo_fill_dynamic( struct if_entry *entry, struct nsi_ndis_ifinfo_
struct if_data ifdata;
if (sysctl( mib, ARRAY_SIZE(mib), NULL, &needed, NULL, 0 ) == -1) goto done;
buf = heap_alloc( needed );
buf = malloc( needed );
if (!buf) goto done;
if (sysctl( mib, ARRAY_SIZE(mib), buf, &needed, NULL, 0 ) == -1) goto done;
for (end = buf + needed; buf < end; buf += ifm->ifm_msglen)
@ -408,7 +407,7 @@ static void ifinfo_fill_dynamic( struct if_entry *entry, struct nsi_ndis_ifinfo_
}
}
done:
heap_free( buf );
free( buf );
}
#endif
}

View File

@ -97,7 +97,6 @@
#include "netiodef.h"
#include "ws2ipdef.h"
#include "tcpmib.h"
#include "wine/heap.h"
#include "wine/nsi.h"
#include "wine/debug.h"
#include "wine/server.h"
@ -269,7 +268,7 @@ struct ipv6_addr_scope *get_ipv6_addr_scope_table( unsigned int *size )
{
if (!table_size) table_size = 4;
else table_size *= 2;
if (!(table = heap_realloc( table, table_size * sizeof(table[0]) )))
if (!(table = realloc( table, table_size * sizeof(table[0]) )))
{
fclose( fp );
goto failed;
@ -301,7 +300,7 @@ struct ipv6_addr_scope *get_ipv6_addr_scope_table( unsigned int *size )
{
if (!table_size) table_size = 4;
else table_size *= 2;
if (!(table = heap_realloc( table, table_size * sizeof(table[0]) )))
if (!(table = realloc( table, table_size * sizeof(table[0]) )))
{
freeifaddrs( addrs );
goto failed;
@ -325,7 +324,7 @@ struct ipv6_addr_scope *get_ipv6_addr_scope_table( unsigned int *size )
return table;
failed:
heap_free( table );
free( table );
return NULL;
}
@ -356,7 +355,7 @@ struct pid_map *get_pid_map( unsigned int *num_entries )
NTSTATUS ret;
char *buffer = NULL, *new_buffer;
if (!(buffer = heap_alloc( buffer_len ))) return NULL;
if (!(buffer = malloc( buffer_len ))) return NULL;
for (;;)
{
@ -371,17 +370,17 @@ struct pid_map *get_pid_map( unsigned int *num_entries )
if (ret != STATUS_INFO_LENGTH_MISMATCH) break;
if (!(new_buffer = heap_realloc( buffer, buffer_len )))
if (!(new_buffer = realloc( buffer, buffer_len )))
{
heap_free( buffer );
free( buffer );
return NULL;
}
buffer = new_buffer;
}
if (!(map = heap_alloc( process_count * sizeof(*map) )))
if (!(map = malloc( process_count * sizeof(*map) )))
{
heap_free( buffer );
free( buffer );
return NULL;
}
@ -400,7 +399,7 @@ struct pid_map *get_pid_map( unsigned int *num_entries )
pos += process->thread_count * sizeof(struct thread_info);
}
heap_free( buffer );
free( buffer );
*num_entries = process_count;
return map;
}
@ -495,7 +494,7 @@ unsigned int find_owning_pid( struct pid_map *map, unsigned int num_entries, UIN
int fd_len = proc_pidinfo( map[i].unix_pid, PROC_PIDLISTFDS, 0, NULL, 0 );
if (fd_len <= 0) continue;
fds = heap_alloc( fd_len );
fds = malloc( fd_len );
if (!fds) continue;
proc_pidinfo( map[i].unix_pid, PROC_PIDLISTFDS, 0, fds, fd_len );
@ -507,12 +506,12 @@ unsigned int find_owning_pid( struct pid_map *map, unsigned int num_entries, UIN
proc_pidfdinfo( map[i].unix_pid, fds[j].proc_fd, PROC_PIDFDSOCKETINFO, &sock, sizeof(sock) );
if (sock.psi.soi_pcb == inode)
{
heap_free( fds );
free( fds );
return map[i].pid;
}
}
heap_free( fds );
free( fds );
}
return 0;
#else
@ -638,7 +637,7 @@ static NTSTATUS tcp_conns_enumerate_all( DWORD filter, struct nsi_tcp_conn_key *
goto err;
}
buf = heap_alloc( len );
buf = malloc( len );
if (!buf)
{
status = STATUS_NO_MEMORY;
@ -728,7 +727,7 @@ static NTSTATUS tcp_conns_enumerate_all( DWORD filter, struct nsi_tcp_conn_key *
num++;
}
err:
heap_free( buf );
free( buf );
}
#else
FIXME( "not implemented\n" );
@ -738,8 +737,8 @@ static NTSTATUS tcp_conns_enumerate_all( DWORD filter, struct nsi_tcp_conn_key *
if (!want_data || num <= *count) *count = num;
else status = STATUS_BUFFER_OVERFLOW;
heap_free( pid_map );
heap_free( addr_scopes );
free( pid_map );
free( addr_scopes );
return status;
}

View File

@ -77,7 +77,6 @@
#include "netiodef.h"
#include "ws2ipdef.h"
#include "udpmib.h"
#include "wine/heap.h"
#include "wine/nsi.h"
#include "wine/debug.h"
#include "wine/server.h"
@ -309,7 +308,7 @@ static NTSTATUS udp_endpoint_enumerate_all( void *key_data, DWORD key_size, void
goto err;
}
buf = heap_alloc( len );
buf = malloc( len );
if (!buf)
{
status = STATUS_NO_MEMORY;
@ -386,7 +385,7 @@ static NTSTATUS udp_endpoint_enumerate_all( void *key_data, DWORD key_size, void
num++;
}
err:
heap_free( buf );
free( buf );
}
#else
FIXME( "not implemented\n" );
@ -396,8 +395,8 @@ static NTSTATUS udp_endpoint_enumerate_all( void *key_data, DWORD key_size, void
if (!want_data || num <= *count) *count = num;
else status = STATUS_BUFFER_OVERFLOW;
heap_free( pid_map );
heap_free( addr_scopes );
free( pid_map );
free( addr_scopes );
return status;
}