From 8d870db811ef4f120d7df3b3f50243b47d94da2f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Nov 2006 16:02:20 +0000 Subject: r19859: Reuse referrent ids when pushing full pointers (still need to avoid pushing the referred object twice) and add test for full pointers. (This used to be commit 1638c8d234dbc85298000685e49570f23dfd0bf8) --- source4/librpc/ndr/libndr.h | 1 + source4/librpc/ndr/ndr_basic.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'source4/librpc') diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index 1076936c1d..fb151e4120 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -88,6 +88,7 @@ struct ndr_push { struct ndr_token_list *switch_list; struct ndr_token_list *relative_list; struct ndr_token_list *nbt_string_list; + struct ndr_token_list *full_ptr_list; /* this is used to ensure we generate unique reference IDs */ uint32_t ptr_count; diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b8f2a8115f..a9cfb558f7 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -485,8 +485,13 @@ _PUBLIC_ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { - ndr->ptr_count++; - ptr = ndr->ptr_count; + /* Check if the pointer already exists and has an id */ + ptr = ndr_token_peek(&ndr->full_ptr_list, p); + if (ptr == 0) { + ndr->ptr_count++; + ptr = ndr->ptr_count; + ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr); + } } return ndr_push_uint32(ndr, NDR_SCALARS, ptr); } -- cgit