Move EAP types (sub-modules) to use talloc
[freeradius.git] / src / modules / rlm_eap / types / rlm_eap_mschapv2 / rlm_eap_mschapv2.c
index b6a8054..759ffdb 100644 (file)
@@ -63,18 +63,6 @@ static void free_data(void *ptr)
        free(data);
 }
 
-/*
- *     Detach the module.
- */
-static int mschapv2_detach(void *arg)
-{
-       rlm_eap_mschapv2_t *inst = (rlm_eap_mschapv2_t *) arg;
-
-       free(inst);
-
-       return 0;
-}
-
 
 /*
  *     Attach the module.
@@ -83,23 +71,16 @@ static int mschapv2_attach(CONF_SECTION *cs, void **instance)
 {
        rlm_eap_mschapv2_t *inst;
 
-       inst = malloc(sizeof(*inst));
-       if (!inst) {
-               radlog(L_ERR, "rlm_eap_mschapv2: out of memory");
-               return -1;
-       }
-       memset(inst, 0, sizeof(*inst));
+       *instance = inst = talloc_zero(cs, rlm_eap_mschapv2_t);
+       if (!inst) return -1;
 
        /*
         *      Parse the configuration attributes.
         */
        if (cf_section_parse(cs, inst, module_config) < 0) {
-               mschapv2_detach(inst);
                return -1;
        }
 
-       *instance = inst;
-
        return 0;
 }
 
@@ -794,5 +775,5 @@ EAP_TYPE rlm_eap_mschapv2 = {
        mschapv2_initiate,              /* Start the initial request */
        NULL,                           /* authorization */
        mschapv2_authenticate,          /* authentication */
-       mschapv2_detach                 /* detach */
+       NULL                            /* detach */
 };