summaryrefslogtreecommitdiffstats
path: root/src/confdb
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2011-12-14 07:20:11 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-02-21 21:28:49 -0500
commit3bea01f01d76e1e95a8239c0d3f67073992136a1 (patch)
tree5da8c3f66905726489fcffba5934db221f6dbed4 /src/confdb
parent3e5caddf4840e40b49ccf24e1ce7b531a692023b (diff)
downloadsssd-3bea01f01d76e1e95a8239c0d3f67073992136a1.tar.gz
sssd-3bea01f01d76e1e95a8239c0d3f67073992136a1.tar.xz
sssd-3bea01f01d76e1e95a8239c0d3f67073992136a1.zip
Don't give memory context in confdb where not needed
Diffstat (limited to 'src/confdb')
-rw-r--r--src/confdb/confdb.c45
-rw-r--r--src/confdb/confdb.h4
2 files changed, 35 insertions, 14 deletions
diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
index 57023f299..04f02b5cc 100644
--- a/src/confdb/confdb.c
+++ b/src/confdb/confdb.c
@@ -337,15 +337,22 @@ failed:
return ret;
}
-int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+int confdb_get_int(struct confdb_ctx *cdb,
const char *section, const char *attribute,
int defval, int *result)
{
char **values = NULL;
long val;
int ret;
+ TALLOC_CTX *tmp_ctx;
- ret = confdb_get_param(cdb, ctx, section, attribute, &values);
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ ret = ENOMEM;
+ goto failed;
+ }
+
+ ret = confdb_get_param(cdb, tmp_ctx, section, attribute, &values);
if (ret != EOK) {
goto failed;
}
@@ -373,27 +380,34 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
val = defval;
}
- talloc_free(values);
+ talloc_free(tmp_ctx);
*result = (int)val;
return EOK;
failed:
- talloc_free(values);
+ talloc_free(tmp_ctx);
DEBUG(1, ("Failed to read [%s] from [%s], error [%d] (%s)\n",
attribute, section, ret, strerror(ret)));
return ret;
}
-long confdb_get_long(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+long confdb_get_long(struct confdb_ctx *cdb,
const char *section, const char *attribute,
long defval, long *result)
{
char **values = NULL;
long val;
int ret;
+ TALLOC_CTX *tmp_ctx;
- ret = confdb_get_param(cdb, ctx, section, attribute, &values);
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ ret = ENOMEM;
+ goto failed;
+ }
+
+ ret = confdb_get_param(cdb, tmp_ctx, section, attribute, &values);
if (ret != EOK) {
goto failed;
}
@@ -416,27 +430,34 @@ long confdb_get_long(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
val = defval;
}
- talloc_free(values);
+ talloc_free(tmp_ctx);
*result = val;
return EOK;
failed:
- talloc_free(values);
+ talloc_free(tmp_ctx);
DEBUG(1, ("Failed to read [%s] from [%s], error [%d] (%s)\n",
attribute, section, ret, strerror(ret)));
return ret;
}
-int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+int confdb_get_bool(struct confdb_ctx *cdb,
const char *section, const char *attribute,
bool defval, bool *result)
{
char **values = NULL;
bool val;
int ret;
+ TALLOC_CTX *tmp_ctx;
- ret = confdb_get_param(cdb, ctx, section, attribute, &values);
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ ret = ENOMEM;
+ goto failed;
+ }
+
+ ret = confdb_get_param(cdb, tmp_ctx, section, attribute, &values);
if (ret != EOK) {
goto failed;
}
@@ -465,13 +486,13 @@ int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
val = defval;
}
- talloc_free(values);
+ talloc_free(tmp_ctx);
*result = val;
return EOK;
failed:
- talloc_free(values);
+ talloc_free(tmp_ctx);
DEBUG(1, ("Failed to read [%s] from [%s], error [%d] (%s)\n",
attribute, section, ret, strerror(ret)));
return ret;
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
index 819e8ff31..18484f023 100644
--- a/src/confdb/confdb.h
+++ b/src/confdb/confdb.h
@@ -343,7 +343,7 @@ int confdb_get_string(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
* @return ERANGE - The value stored in the ConfDB was outside the range
* [INT_MIN..INT_MAX]
*/
-int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+int confdb_get_int(struct confdb_ctx *cdb,
const char *section, const char *attribute,
int defval, int *result);
@@ -372,7 +372,7 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
* single-valued, or the value was not a boolean.
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
-int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+int confdb_get_bool(struct confdb_ctx *cdb,
const char *section, const char *attribute,
bool defval, bool *result);