From 9fb5ab9a7bd8e881684c60c6063540aa9af3c7b2 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Mon, 28 Apr 2003 18:51:35 +0000 Subject: [PATCH] Incorporate krb5_os_context directly into krb5_context, since they're always allocated and freed at the same time, even if in different files. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15378 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/ChangeLog | 5 +++++ src/include/k5-int.h | 11 ++++++++++- src/lib/krb5/os/ChangeLog | 6 ++++++ src/lib/krb5/os/init_os_ctx.c | 16 +--------------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 53947082b..15b749707 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,8 @@ +2003-04-28 Ken Raeburn + + * k5-int.h (struct _krb5_context): Change os_context to be an + array of one _krb5_os_context instead of a void pointer. + 2003-04-17 Sam Hartman * k5-int.h: Add encode_krb5_setpw_req diff --git a/src/include/k5-int.h b/src/include/k5-int.h index ec7381bcf..35d924bc3 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -983,7 +983,16 @@ struct _krb5_context { int in_tkt_ktype_count; krb5_enctype *tgs_ktypes; int tgs_ktype_count; - void *os_context; + /* This used to be a void*, but since we always allocate them + together (though in different source files), and the types + are declared in the same header, might as well just combine + them. + + The array[1] is so the existing code treating the field as + a pointer will still work. For cleanliness, it should + eventually get changed to a single element instead of an + array. */ + struct _krb5_os_context os_context[1]; char *default_realm; profile_t profile; void *db_context; diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 2647d22f2..a53810545 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,9 @@ +2003-04-28 Ken Raeburn + + * init_os_ctx.c (krb5_os_init_context, krb5_os_free_context): + Don't allocate or free the os_context, since it's now a direct + member of the krb5_context, not separately allocated storage. + 2003-04-27 Sam Hartman * changepw.c (krb5_change_set_password): Call diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c index eb2321d42..7f2c2d593 100644 --- a/src/lib/krb5/os/init_os_ctx.c +++ b/src/lib/krb5/os/init_os_ctx.c @@ -333,17 +333,8 @@ krb5_os_init_context(krb5_context ctx) krb5_os_context os_ctx; krb5_error_code retval = 0; - if (ctx->os_context) - return 0; - - os_ctx = malloc(sizeof(struct _krb5_os_context)); - if (!os_ctx) - return ENOMEM; - memset(os_ctx, 0, sizeof(struct _krb5_os_context)); + os_ctx = ctx->os_context; os_ctx->magic = KV5M_OS_CONTEXT; - - ctx->os_context = (void *) os_ctx; - os_ctx->time_offset = 0; os_ctx->usec_offset = 0; os_ctx->os_flags = 0; @@ -453,9 +444,6 @@ krb5_os_free_context(krb5_context ctx) os_ctx = ctx->os_context; - if (!os_ctx) - return; - if (os_ctx->default_ccname) { free(os_ctx->default_ccname); os_ctx->default_ccname = 0; @@ -467,8 +455,6 @@ krb5_os_free_context(krb5_context ctx) } os_ctx->magic = 0; - free(os_ctx); - ctx->os_context = 0; if (ctx->profile) { profile_release(ctx->profile); -- 2.26.2