Solved

Rpc binding vector

Posted on 1998-03-31
3
304 Views
Last Modified: 2006-11-17
In microsoft rpc Rpc_Binding_vector  is a data structure, defined in header  rpcdce.h. It contains two elements, 1. count  showing number of binding handles in binding handle array 2. array of binding handles
In include file rpcdce.h the array size has been given as 1.
My doubt is it any way possible for a binding vector to have more than one binding handle ? if yes how?
0
Comment
Question by:sudhir033198
  • 3
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
Comment Utility
Of course it is!
Example comming...

0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
Let's take the following structure as an example:

    struct X
    {
        long count;
        int elements[1];
    };

The thing to remember is that the difference between "real macho" languages like C and wimpy Wirth languages is that in C it is legal, moral and accepted to lie to the compiler.
C allows accessing out-of-bounds array elements.  The following code is legal:

    struct X x;
    x.elements[0] = x.elements[42] = x.elements[-1000];

The compiler will happily generate code to access the n'th element, whatever n is.
So, the tricky part is allocating enough elements.  Static and automatic allocations will not work (obviously) but then, there's malloc().

Let's write a function that will return a pointer to a dynamically allocated structure with n elements (modulo typing errors):

    struct X * AllocateStruct(int n)
    {
        struct X *p = (struct X *) malloc(sizeof(long) + n * sizeof(int));
        p->count = n;
        return p;
    }

And use it thus:

    struct X *px;
    px = AllocateStruct(100);
    /* Do some stuff involving px */
    free(px);

OK?
0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
Hello???
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now