Changeset 140922 in webkit


Ignore:
Timestamp:
Jan 26, 2013 5:36:36 PM (11 years ago)
Author:
weinig@apple.com
Message:

Simplify environment creation in XPC service re-exec
https://bugs.webkit.org/show_bug.cgi?id=108017

Reviewed by Dan Bernstein.

  • Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h:

(WebKit::XPCServiceEventHandler):
There is no need to copy these strings.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r140921 r140922  
     12013-01-26  Sam Weinig  <sam@webkit.org>
     2
     3        Simplify environment creation in XPC service re-exec
     4        https://bugs.webkit.org/show_bug.cgi?id=108017
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h:
     9        (WebKit::XPCServiceEventHandler):
     10        There is no need to copy these strings.
     11
    1122013-01-26  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h

    r140920 r140922  
    9797                size_t numberOfEnvironmentVariables = xpc_array_get_count(environmentArray);
    9898
    99                 char** environment = (char**)malloc(numberOfEnvironmentVariables * sizeof(char*) + 1);
    100                 for (size_t i = 0; i < numberOfEnvironmentVariables; ++i) {
    101                     const char* string =  xpc_array_get_string(environmentArray, i);
    102                     size_t stringLength = strlen(string);
    103 
    104                     char* environmentVariable = (char*)malloc(stringLength + 1);
    105                     memcpy(environmentVariable, string, stringLength);
    106                     environmentVariable[stringLength] = '\0';
    107 
    108                     environment[i] = environmentVariable;
    109                 }
     99                const char** environment = (const char**)malloc(numberOfEnvironmentVariables * sizeof(char*) + 1);
     100                for (size_t i = 0; i < numberOfEnvironmentVariables; ++i)
     101                    environment[i] = xpc_array_get_string(environmentArray, i);
    110102                environment[numberOfEnvironmentVariables] = 0;
    111103
    112104                pid_t processIdentifier = 0;
    113                 posix_spawn(&processIdentifier, path, 0, &attr, const_cast<char**>(args), environment);
     105                posix_spawn(&processIdentifier, path, 0, &attr, const_cast<char**>(args), const_cast<char**>(environment));
    114106
    115107                posix_spawnattr_destroy(&attr);
Note: See TracChangeset for help on using the changeset viewer.