ndr->flags = 0;
ndr->alloc_size = NDR_BASE_MARSHALL_SIZE;
- ndr->data = talloc(ndr, ndr->alloc_size);
+ ndr->data = talloc_array_p(ndr, uint8_t, ndr->alloc_size);
if (!ndr->data) {
return NULL;
}
if (size > ndr->alloc_size) {
ndr->alloc_size = size;
}
- ndr->data = talloc_realloc(ndr, ndr->data, ndr->alloc_size);
+ ndr->data = talloc_realloc(ndr, ndr->data, uint8_t, ndr->alloc_size);
if (!ndr->data) {
return ndr_push_error(ndr, NDR_ERR_ALLOC, "Failed to push_expand to %u",
ndr->alloc_size);
return NT_STATUS_OK;
}
+
+/*
+ generic ndr_size_*() handler for structures
+*/
+size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push)
+{
+ struct ndr_push *ndr;
+ NTSTATUS status;
+ size_t ret;
+
+ ndr = ndr_push_init_ctx(NULL);
+ if (!ndr) return 0;
+ ndr->flags |= flags;
+ status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p));
+ if (!NT_STATUS_IS_OK(status)) {
+ return 0;
+ }
+ ret = ndr->offset;
+ talloc_free(ndr);
+ return ret;
+}