summaryrefslogtreecommitdiff
path: root/subversion/libsvn_client/ctx.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_client/ctx.c')
-rw-r--r--subversion/libsvn_client/ctx.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/subversion/libsvn_client/ctx.c b/subversion/libsvn_client/ctx.c
index 185b91e..05a5eec 100644
--- a/subversion/libsvn_client/ctx.c
+++ b/subversion/libsvn_client/ctx.c
@@ -27,6 +27,7 @@
/*** Includes. ***/
+#include <stddef.h>
#include <apr_pools.h>
#include "svn_hash.h"
#include "svn_client.h"
@@ -34,6 +35,8 @@
#include "private/svn_wc_private.h"
+#include "client.h"
+
/*** Code. ***/
@@ -76,6 +79,20 @@ call_conflict_func(svn_wc_conflict_result_t **result,
return SVN_NO_ERROR;
}
+/* The magic number in client_ctx_t.magic_id. */
+#define CLIENT_CTX_MAGIC APR_UINT64_C(0xDEADBEEF600DF00D)
+
+svn_client__private_ctx_t *
+svn_client__get_private_ctx(svn_client_ctx_t *ctx)
+{
+ svn_client__private_ctx_t *const private_ctx =
+ (void*)((char *)ctx - offsetof(svn_client__private_ctx_t, public_ctx));
+ SVN_ERR_ASSERT_NO_RETURN(&private_ctx->public_ctx == ctx);
+ SVN_ERR_ASSERT_NO_RETURN(0 == private_ctx->magic_null);
+ SVN_ERR_ASSERT_NO_RETURN(CLIENT_CTX_MAGIC == private_ctx->magic_id);
+ return private_ctx;
+}
+
svn_error_t *
svn_client_create_context2(svn_client_ctx_t **ctx,
apr_hash_t *cfg_hash,
@@ -83,23 +100,29 @@ svn_client_create_context2(svn_client_ctx_t **ctx,
{
svn_config_t *cfg_config;
- *ctx = apr_pcalloc(pool, sizeof(svn_client_ctx_t));
+ svn_client__private_ctx_t *const private_ctx =
+ apr_pcalloc(pool, sizeof(*private_ctx));
+ svn_client_ctx_t *const public_ctx = &private_ctx->public_ctx;
+
+ private_ctx->magic_null = 0;
+ private_ctx->magic_id = CLIENT_CTX_MAGIC;
- (*ctx)->notify_func2 = call_notify_func;
- (*ctx)->notify_baton2 = *ctx;
+ public_ctx->notify_func2 = call_notify_func;
+ public_ctx->notify_baton2 = public_ctx;
- (*ctx)->conflict_func2 = call_conflict_func;
- (*ctx)->conflict_baton2 = *ctx;
+ public_ctx->conflict_func2 = call_conflict_func;
+ public_ctx->conflict_baton2 = public_ctx;
- (*ctx)->config = cfg_hash;
+ public_ctx->config = cfg_hash;
if (cfg_hash)
cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
else
cfg_config = NULL;
- SVN_ERR(svn_wc_context_create(&(*ctx)->wc_ctx, cfg_config, pool,
- pool));
+ SVN_ERR(svn_wc_context_create(&public_ctx->wc_ctx, cfg_config,
+ pool, pool));
+ *ctx = public_ctx;
return SVN_NO_ERROR;
}