123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include "precompile.h"
- #include "memutil.h"
- #include "sp_rsn.h"
- void sp_rsn_context_init_original(sp_uid_t rsn, int original_type, sp_rsn_context_t *ctx)
- {
- ctx->depth = 0;
- ctx->original_type = original_type;
- ctx->previous_rsn = SP_RSN_UNKNOWN;
- ctx->current_rsn = rsn;
- }
- void sp_rsn_context_init_downstream(sp_uid_t rsn, const sp_rsn_context_t *upstream, sp_rsn_context_t *ctx)
- {
- ctx->depth = upstream->depth + 1;
- ctx->original_type = upstream->original_type;
- ctx->previous_rsn = upstream->current_rsn;
- ctx->current_rsn = rsn;
- }
- sp_rsn_context_t *sp_rsn_context_create_original(sp_uid_t rsn, int original_type)
- {
- sp_rsn_context_t *ctx = MALLOC_T(sp_rsn_context_t);
- if (ctx) {
- sp_rsn_context_init_original(rsn, original_type, ctx);
- }
- return ctx;
- }
- sp_rsn_context_t *sp_rsn_context_create_downstream(sp_uid_t rsn, const sp_rsn_context_t *upstream)
- {
- sp_rsn_context_t *ctx = MALLOC_T(sp_rsn_context_t);
- if (ctx) {
- sp_rsn_context_init_downstream(rsn, upstream, ctx);
- }
- return ctx;
- }
- void sp_rsn_context_destroy(sp_rsn_context_t *ctx)
- {
- free(ctx);
- }
- void sp_rsn_context_copy(sp_rsn_context_t *dst_ctx, const sp_rsn_context_t *src_ctx)
- {
- dst_ctx->previous_rsn = src_ctx->previous_rsn;
- dst_ctx->current_rsn = src_ctx->current_rsn;
- dst_ctx->original_type = src_ctx->original_type;
- dst_ctx->depth = src_ctx->depth;
- }
- sp_rsn_context_t *sp_rsn_context_clone(const sp_rsn_context_t *src_ctx)
- {
- sp_rsn_context_t *dst_ctx = MALLOC_T(sp_rsn_context_t);
- if (dst_ctx) {
- sp_rsn_context_copy(dst_ctx, src_ctx);
- }
- return dst_ctx;
- }
|