views:

128

answers:

2

What is the difference between:

thread_envs[i] = soap_copy(&env);

and

thread_envs[i] = soap_new();

Sould we use one of them or both?

+1  A: 

From the documentation:

struct soap *soap_new()

Allocates, initializes, and returns a pointer to a runtime environment

struct soap *soap_copy(struct soap *soap)

Allocates a new runtime environment and copies contents of the environment such that the new environment does not share any data with the original environment

Andreas Bonini
thanks! can we use them in the same program?
Apollo
+1  A: 

The answer really depends on your intention: do you want a new, blank environment for each thread (use soap_new()) or a separate copy of the existing environment for each thread (use soap_copy()). The process of copying the environment probably has some additional overhead, so all other things being equal, use soap_new().

mrkj