Skip to content

Commit

Permalink
Use talloc for handles
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Mar 16, 2013
1 parent 5a627b9 commit a1050a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/modules/rlm_redis/rlm_redis.c
Expand Up @@ -43,7 +43,7 @@ static const CONF_PARSER module_config[] = {
{ NULL, -1, 0, NULL, NULL} /* end the list */
};

static int redis_delete_conn(UNUSED void *ctx, void *conn)
static int conn_delete(UNUSED void *ctx, void *conn)
{
REDISSOCK *dissocket = conn;

Expand All @@ -54,11 +54,11 @@ static int redis_delete_conn(UNUSED void *ctx, void *conn)
dissocket->reply = NULL;
}

free(dissocket);
talloc_free(dissocket);
return 1;
}

static void *redis_create_conn(void *ctx)
static void *conn_create(void *ctx)
{
REDIS_INST *inst = ctx;
REDISSOCK *dissocket = NULL;
Expand Down Expand Up @@ -130,8 +130,7 @@ static void *redis_create_conn(void *ctx)
}
}

dissocket = rad_malloc(sizeof(*dissocket));
memset(dissocket, 0, sizeof(*dissocket));
dissocket = talloc_zero(inst, REDISSOCK);
dissocket->conn = conn;

return dissocket;
Expand Down Expand Up @@ -308,8 +307,8 @@ static int redis_instantiate(CONF_SECTION *conf, void **instance)
xlat_register(inst->xlat_name, redis_xlat, inst);

inst->pool = fr_connection_pool_init(conf, inst,
redis_create_conn, NULL,
redis_delete_conn);
conn_create, NULL,
conn_delete);
if (!inst->pool) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_redis/rlm_redis.h
Expand Up @@ -42,7 +42,7 @@ typedef struct redis_socket_t {
typedef struct rlm_redis_t REDIS_INST;

typedef struct rlm_redis_t {
char *xlat_name;
const char *xlat_name;

char *hostname;
int port;
Expand Down

0 comments on commit a1050a6

Please sign in to comment.