On Tue, Jan 04, 2011, Andrey Kulikov wrote: > If we take a look at any ENGINE_load_XXX function, we find that they all has > similar structure: > > ENGINE *toadd = engine_XXX(); > if(!toadd) return; > ENGINE_add(toadd); > ENGINE_free(toadd); > ERR_clear_error(); > > My question is: why we need call ENGINE_free(toadd) ??
To avoid a memory leak. When you call engine_XXX() you get a reference to the ENGINE. When it is added to the ENGINE list the reference count is incremented. When you call ENGINE_free() the count is decremented and the ENGINE is freed only if the reference count is zero. Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial tech support now available see: http://www.openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [email protected] Automated List Manager [email protected]
