+ FOO *data = openssl_ctx_get_data(ctx, OPENSSL_CTX_FOO_INDEX, &foo_method);
+
+=head2 Run Once
+
+ void foo_cleanup(OPENSSL_CTX *ctx)
+ {
+ /* Free foo resources associated with ctx */
+ }
+
+ static openssl_ctx_run_once_fn do_foo_init;
+ static int do_foo_init(OPENSSL_CTX *ctx)
+ {
+ /* Allocate and initialise some foo resources and associated with ctx */
+ return openssl_ctx_onfree(ctx, &foo_cleanup)
+ }
+
+ int foo_some_function(OPENSSL_CTX *ctx)
+ {
+ if (!openssl_ctx_run_once(ctx,
+ OPENSSL_CTX_FOO_RUN_ONCE_INDEX,
+ do_foo_init))
+ return 0;
+
+ /* Do some work using foo resources in ctx */
+ }
+