Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Rpc binding vector

Posted on 1998-03-31
3
Medium Priority
?
324 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 40 total points
ID: 1257967
Of course it is!
Example comming...

0
 
LVL 11

Expert Comment

by:alexo
ID: 1257968
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
ID: 1257969
Hello???
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses
Course of the Month20 days, 19 hours left to enroll

810 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