VirtualBox

Changeset 16378 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Jan 29, 2009 4:51:48 PM (16 years ago)
Author:
vboxsync
Message:

string.cpp: !RT_SUCCESS -> RT_FAILURE, propsal for saving one memcpy+alloc/free.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/string.cpp

    r16369 r16378  
    5353            size_t i = pos;
    5454            while (*psz && i--)
    55                 if (!(RT_SUCCESS(RTStrGetCpEx(&psz, &cp))))
     55                if (RT_FAILURE(RTStrGetCpEx(&psz, &cp)))
    5656                    return ret;     // return empty string on bad encoding
    5757
     
    6565                i = n;
    6666                while (*psz && i--)
    67                     if (!(RT_SUCCESS(RTStrGetCpEx(&psz, &cp))))
     67                    if (RT_FAILURE(RTStrGetCpEx(&psz, &cp)))
    6868                        return ret;     // return empty string on bad encoding
    6969
    7070                size_t len = psz - pFirst;
     71#if 1
    7172                char *psz = (char*)RTMemAlloc(len + 1);
    7273                memcpy(psz, pFirst, len);
     
    7475                ret = psz;
    7576                RTMemFree(psz);
     77#else /* A proposal that saves a memcpy and alloc/free: */
     78                ret.alloc(len + 1);
     79                memcpy(ret.str, pFirst, len);
     80                ret.str[len] = '\0';
     81#endif
    7682            }
    7783        }
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