int ossl_prop_defn_set(const char *prop, OSSL_PROPERTY_LIST *pl)
{
    PROPERTY_DEFN_ELEM elem, *old, *p = NULL;
    size_t len;
    if (prop == NULL)
        return 1;
    if (pl == NULL) {
        elem.prop = prop;
        lh_PROPERTY_DEFN_ELEM_delete(property_defns, &elem);
        return 1;
    }
    len = strlen(prop);
    p = OPENSSL_malloc(sizeof(*p) + len);
    if (p != NULL) {
        p->prop = p->body;
        p->defn = pl;
        memcpy(p->body, prop, len + 1);
        old = lh_PROPERTY_DEFN_ELEM_insert(property_defns, p);
        if (old != NULL) {
            property_defn_free(old);
            return 1;
        }
        if (!lh_PROPERTY_DEFN_ELEM_error(property_defns))
            return 1;
    }
    OPENSSL_free(p);
    return 0;
}
['static int test_register_deregister(void)\n{\n    static const struct {\n        int nid;\n        const char *prop;\n        char *impl;\n    } impls[] = {\n        { 6, "position=1", "a" },\n        { 6, "position=2", "b" },\n        { 6, "position=3", "c" },\n        { 6, "position=4", "d" },\n    };\n    size_t i;\n    int ret = 0;\n    OSSL_METHOD_STORE *store;\n    if (!TEST_ptr(store = ossl_method_store_new())\n        || !add_property_names("position", NULL))\n        goto err;\n    for (i = 0; i < OSSL_NELEM(impls); i++)\n        if (!TEST_true(ossl_method_store_add(store, impls[i].nid, impls[i].prop,\n                                             impls[i].impl, NULL))) {\n            TEST_note("iteration %zd", i + 1);\n            goto err;\n        }\n    for (i = 0; i < OSSL_NELEM(impls); i++) {\n        const size_t j = (1 + i * 3) % OSSL_NELEM(impls);\n        int nid = impls[j].nid;\n        void *impl = impls[j].impl;\n        if (!TEST_true(ossl_method_store_remove(store, nid, impl))\n            || !TEST_false(ossl_method_store_remove(store, nid, impl))) {\n            TEST_note("iteration %zd, position %zd", i + 1, j + 1);\n            goto err;\n        }\n    }\n    if (TEST_false(ossl_method_store_remove(store, impls[0].nid, impls[0].impl)))\n        ret = 1;\nerr:\n    ossl_method_store_free(store);\n    return ret;\n}', 'int ossl_method_store_add(OSSL_METHOD_STORE *store,\n                          int nid, const char *properties,\n                          void *method, void (*method_destruct)(void *))\n{\n    ALGORITHM *alg = NULL;\n    IMPLEMENTATION *impl;\n    int ret = 0;\n    if (nid <= 0 || method == NULL || store == NULL)\n        return 0;\n    if (properties == NULL)\n        properties = "";\n    impl = OPENSSL_malloc(sizeof(*impl));\n    if (impl == NULL)\n        return 0;\n    impl->method = method;\n    impl->method_destruct = method_destruct;\n    ossl_property_write_lock(store);\n    ossl_method_cache_flush(store, nid);\n    if ((impl->properties = ossl_prop_defn_get(properties)) == NULL) {\n        if ((impl->properties = ossl_parse_property(properties)) == NULL)\n            goto err;\n        ossl_prop_defn_set(properties, impl->properties);\n    }\n    alg = ossl_method_store_retrieve(store, nid);\n    if (alg == NULL) {\n        if ((alg = OPENSSL_zalloc(sizeof(*alg))) == NULL\n                || (alg->impls = sk_IMPLEMENTATION_new_null()) == NULL\n                || (alg->cache = lh_QUERY_new(&query_hash, &query_cmp)) == NULL)\n            goto err;\n        alg->nid = nid;\n        if (!ossl_method_store_insert(store, alg))\n            goto err;\n    }\n    if (sk_IMPLEMENTATION_push(alg->impls, impl))\n        ret = 1;\n    ossl_property_unlock(store);\n    if (ret == 0)\n        impl_free(impl);\n    return ret;\nerr:\n    ossl_property_unlock(store);\n    alg_cleanup(0, alg);\n    impl_free(impl);\n    return 0;\n}', 'int ossl_prop_defn_set(const char *prop, OSSL_PROPERTY_LIST *pl)\n{\n    PROPERTY_DEFN_ELEM elem, *old, *p = NULL;\n    size_t len;\n    if (prop == NULL)\n        return 1;\n    if (pl == NULL) {\n        elem.prop = prop;\n        lh_PROPERTY_DEFN_ELEM_delete(property_defns, &elem);\n        return 1;\n    }\n    len = strlen(prop);\n    p = OPENSSL_malloc(sizeof(*p) + len);\n    if (p != NULL) {\n        p->prop = p->body;\n        p->defn = pl;\n        memcpy(p->body, prop, len + 1);\n        old = lh_PROPERTY_DEFN_ELEM_insert(property_defns, p);\n        if (old != NULL) {\n            property_defn_free(old);\n            return 1;\n        }\n        if (!lh_PROPERTY_DEFN_ELEM_error(property_defns))\n            return 1;\n    }\n    OPENSSL_free(p);\n    return 0;\n}']