VirtualBox

Ignore:
Timestamp:
Jan 5, 2009 10:30:45 AM (16 years ago)
Author:
vboxsync
Message:

NAT: malloc/free/realloc/strdup => iprt functions; fixed VBOX_WITH_SLIRP_MEMORY_CHECK

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/ip_icmp.c

    r15676 r15791  
    140140# endif /* VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */
    141141    pData->szIcmpBuffer = sizeof(ICMP_ECHO_REPLY) * 10;
    142     pData->pvIcmpBuffer = malloc(pData->szIcmpBuffer);
     142    pData->pvIcmpBuffer = RTMemAlloc(pData->szIcmpBuffer);
    143143#endif /* RT_OS_WINDOWS */
    144144    LIST_INIT(&pData->icmp_msg_head);
     
    249249    if (found == 1 && icm == NULL)
    250250    {
    251         icm = malloc(sizeof(struct icmp_msg));
     251        icm = RTMemAlloc(sizeof(struct icmp_msg));
    252252        icm->im_m = so->so_m;
    253253        icm->im_so = so;
     
    273273    ip = mtod(m, struct ip *);
    274274    Assert(ip->ip_p == IPPROTO_ICMP);
    275     icm = malloc(sizeof(struct icmp_msg));
     275    icm = RTMemAlloc(sizeof(struct icmp_msg));
    276276    icm->im_m = m;
    277277    LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list);
  • trunk/src/VBox/Devices/Network/slirp/ip_input.c

    r15636 r15791  
    308308    if (fp == NULL)
    309309    {
    310         fp = malloc(sizeof(struct ipq_t));
     310        fp = RTMemAlloc(sizeof(struct ipq_t));
    311311        if (fp == NULL)
    312312            goto dropfrag;
  • trunk/src/VBox/Devices/Network/slirp/mbuf.c

    r15453 r15791  
    5757    if (m_freelist.m_next == &m_freelist)
    5858    {
    59         m = (struct mbuf *)malloc(msize);
     59        m = (struct mbuf *)RTMemAlloc(msize);
    6060        if (m == NULL)
    6161            goto end_error;
     
    103103        /* If it's M_EXT, free() it */
    104104        if (m->m_flags & M_EXT)
    105             free(m->m_ext);
     105            RTMemFree(m->m_ext);
    106106
    107107        /*
     
    110110        if (m->m_flags & M_DOFREE)
    111111        {
    112             free(m);
     112            RTMemFree(m);
    113113            mbuf_alloced--;
    114114        }
     
    155155    {
    156156        datasize = m->m_data - m->m_ext;
    157         m->m_ext = (char *)realloc(m->m_ext, size);
     157        m->m_ext = (char *)RTMemRealloc(m->m_ext, size);
    158158#if 0
    159159        if (m->m_ext == NULL)
     
    166166        char *dat;
    167167        datasize = m->m_data - m->m_dat;
    168         dat = (char *)malloc(size);
     168        dat = (char *)RTMemAlloc(size);
    169169#if 0
    170170        if (dat == NULL)
  • trunk/src/VBox/Devices/Network/slirp/misc.c

    r15453 r15791  
    7070
    7171    tmp_ptr = *ex_ptr;
    72     *ex_ptr = (struct ex_list *)malloc(sizeof(struct ex_list));
     72    *ex_ptr = (struct ex_list *)RTMemAlloc(sizeof(struct ex_list));
    7373    (*ex_ptr)->ex_fport = port;
    7474    (*ex_ptr)->ex_addr = addr;
    7575    (*ex_ptr)->ex_pty = do_pty;
    76     (*ex_ptr)->ex_exec = strdup(exec);
     76    (*ex_ptr)->ex_exec = RTStrDup(exec);
    7777    (*ex_ptr)->ex_next = tmp_ptr;
    7878    return 0;
  • trunk/src/VBox/Devices/Network/slirp/sbuf.c

    r15293 r15791  
    1919sbfree(struct sbuf *sb)
    2020{
    21     free(sb->sb_data);
     21    RTMemFree(sb->sb_data);
    2222}
    2323
     
    4646        if (sb->sb_datalen != size)
    4747        {
    48             sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)realloc(sb->sb_data, size);
     48            sb->sb_wptr =
     49            sb->sb_rptr =
     50            sb->sb_data = (char *)RTMemRealloc(sb->sb_data, size);
    4951            sb->sb_cc = 0;
    5052            if (sb->sb_wptr)
     
    5658    else
    5759    {
    58         sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)malloc(size);
     60        sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)RTMemAlloc(size);
    5961        sb->sb_cc = 0;
    6062        if (sb->sb_wptr)
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r15769 r15791  
    337337{
    338338    int fNATfailed = 0;
    339     PNATState pData = malloc(sizeof(NATState));
     339    PNATState pData = RTMemAlloc(sizeof(NATState));
    340340    *ppData = pData;
    341341    if (!pData)
     
    10701070{
    10711071#ifdef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC
    1072     uint8_t *buf = malloc(1600); /* XXX:temporal solution */
     1072    uint8_t *buf = RTMemAlloc(1600); /* XXX:temporal solution */
    10731073    struct ethhdr *eh = (struct ethhdr *)buf;
    10741074
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r15575 r15791  
    2828#define LOG_GROUP LOG_GROUP_DRV_NAT
    2929#include <VBox/log.h>
    30 #ifdef VBOX_WITH_SLIRP_MEMORY_CHECK
    31 # define RTMEM_WRAP_TO_EF_APIS
    32 #endif /* VBOX_WITH_SLIRP_MEMORY_CHECK */
    3330#include <iprt/mem.h>
    3431#ifdef RT_OS_WINDOWS
     
    4138#include <VBox/types.h>
    4239
    43 #define malloc(a)       RTMemAlloc(a)
    44 #define free(a)         RTMemFree(a)
    45 #define realloc(a,b)    RTMemRealloc(a, b)
     40#undef malloc
     41#define malloc          dont_use_malloc
     42#undef free
     43#define free(a)         dont_use_free
     44#undef realloc
     45#define realloc(a,b)    dont_use_realloc
     46#undef strdup
     47#define strdup(a)       dont_use_strdup
    4648
    4749#include "slirp_config.h"
     
    168170#ifdef GETTIMEOFDAY_ONE_ARG
    169171# define gettimeofday(x, y) gettimeofday(x)
    170 #endif
    171 
    172 /* Systems lacking strdup() definition in <string.h>. */
    173 #if defined(ultrix)
    174 char *strdup _P((const char *));
    175 #endif
    176 
    177 /* Systems lacking malloc() definition in <stdlib.h>. */
    178 #if defined(ultrix) || defined(hcx)
    179 void *malloc _P((size_t arg));
    180 void free _P((void *ptr));
    181172#endif
    182173
  • trunk/src/VBox/Devices/Network/slirp/slirp_config.h

    r14964 r15791  
    5252 */
    5353
    54 /* Ignore this */
    55 #undef DUMMY_PPP
    56 
    5754#ifdef _MSC_VER
    5855#undef HAVE_UNISTD_H
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r15672 r15791  
    6060    struct socket *so;
    6161
    62     so = (struct socket *)malloc(sizeof(struct socket));
     62    so = (struct socket *)RTMemAlloc(sizeof(struct socket));
    6363    if(so)
    6464    {
  • trunk/src/VBox/Devices/Network/slirp/tcp_input.c

    r15472 r15791  
    115115     * just drop the pkt.
    116116     */
    117     te = malloc(sizeof(struct tseg_qent));
     117    te = RTMemAlloc(sizeof(struct tseg_qent));
    118118    if (te == NULL)
    119119    {
  • trunk/src/VBox/Devices/Network/slirp/tcp_subr.c

    r15453 r15791  
    186186    register struct tcpcb *tp;
    187187
    188     tp = (struct tcpcb *)malloc(sizeof(*tp));
     188    tp = (struct tcpcb *)RTMemAlloc(sizeof(*tp));
    189189    if (tp == NULL)
    190190        return ((struct tcpcb *)0);
  • trunk/src/VBox/Devices/Network/slirp/udp.c

    r15636 r15791  
    564564                {
    565565                    /* no entry for so, create new */
    566                     req = (struct talk_request *)malloc(sizeof(struct talk_request));
     566                    req = (struct talk_request *)RTMemAlloc(sizeof(struct talk_request));
    567567                    req->udp_so = so;
    568568                    req->tcp_so = solisten(0,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette