~ubuntu-branches/ubuntu/vivid/virtualbox-ose/vivid

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/common/string/string.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-09-14 18:25:07 UTC
  • mfrom: (0.4.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090914182507-c98g07mq16hjmn6d
Tags: 3.0.6-dfsg-1ubuntu1
* Merge from debian unstable (LP: #429697), remaining changes:
  - Enable DKMS support on virtualbox host and guest modules (LP: #267097)
    - Drop virtualbox-ose{-guest,}-modules-* package templates
    - Recommend *-source instead of *-modules packages
    - Replace error messages related to missing/mismatched
      kernel module accordingly
  - Autoload kernel module
    - LOAD_VBOXDRV_MODULE=1 in virtualbox-ose.default
  - Disable update action
    - patches/u01-disable-update-action.dpatch
  - Virtualbox should go in Accessories, not in System tools (LP: #288590)
    - virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add apport hook
    - virtualbox-ose.files/source_virtualbox-ose.py
    - virtualbox-ose.install
  - Add launchpad integration
    - control
    - lpi-bug.xpm
    - patches/u02-lp-integration.dpatch
  - virtualbox, virtualbox-* (names of the upstream proprietary packages)
    conflict with virtualbox-ose (LP: #379878)
* Make debug package depend on normal or guest utils package
* Drop patches/22-pulseaudio-stubs.dpatch (applied upstream)
* Rename Ubuntu specific patches to uXX-*.dpatch
* Fix lintian warnings in maintainer scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
 */
62
62
RTDECL(char *) RTStrDup(const char *pszString)
63
63
{
64
 
    Assert(VALID_PTR(pszString));
 
64
    AssertPtr(pszString);
65
65
    size_t cch = strlen(pszString) + 1;
66
66
    char *psz = (char *)RTMemAlloc(cch);
67
67
    if (psz)
80
80
 */
81
81
RTDECL(int)  RTStrDupEx(char **ppszString, const char *pszString)
82
82
{
83
 
    Assert(VALID_PTR(ppszString));
84
 
    Assert(VALID_PTR(pszString));
 
83
    AssertPtr(ppszString);
 
84
    AssertPtr(pszString);
85
85
 
86
86
    size_t cch = strlen(pszString) + 1;
87
87
    char *psz = (char *)RTMemAlloc(cch);
94
94
    return VERR_NO_MEMORY;
95
95
}
96
96
 
 
97
 
 
98
/**
 
99
 * Allocates a new copy of the given UTF-8 substring.
 
100
 *
 
101
 * @returns Pointer to the allocated UTF-8 substring.
 
102
 * @param   pszString       UTF-8 string to duplicate.
 
103
 * @param   cchMax          The max number of chars to duplicate, not counting
 
104
 *                          the terminator.
 
105
 */
 
106
RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax)
 
107
{
 
108
    AssertPtr(pszString);
 
109
    char  *pszEnd = (char *)memchr(pszString, '\0', cchMax);
 
110
    size_t cch    = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax;
 
111
    char  *pszDst = (char *)RTMemAlloc(cch);
 
112
    if (pszDst)
 
113
    {
 
114
        memcpy(pszDst, pszString, cch);
 
115
        pszDst[cch] = '\0';
 
116
    }
 
117
    return pszDst;
 
118
}