libmsrpc for Samba 3

derrell at derrell at
Wed Jul 20 16:53:42 GMT 2005

Chris Nicholls <cnicholl at> writes:

>>The initialize_operation() function can either set reasonable default values
>>for each of the fields in "op" or set each parameter to an illegal value so
>>that uninitialized fields can be caught in dcerpc_spoolss_OpenPrinter().
>>Note that initialize_operation() specifically does NOT take parameters to
>>fill in the structure.  That would, of course, eliminate the utility of the
>>control block.  The function simply initialize all fields to reasonable
>>defaults or illegal values.
> I considered something like that but it seems to me like using an 
> initialize_operation() function is adding to complexity, there is a 
> function just to prepare values for the second function call.

Yup, and given my feeling that programmers would tend to initialize all of the
fields of a structure, I do not feel this function is really necessary.

> Also, if something like this were used I would prefer a function like
> get_some_control_block() that would also allocate memory for such a
> structure and return it.  I guess in my mind that just seems like it
> accomplishes more.
> What do you think?

That's better than initialize_structure() if the structures tend to be
allocated.  My suspicion is that you'll find that most of the time, the
operation structure is for local use and can be a stack variable, so it need
not have the overhead of malloc/free.



More information about the samba-technical mailing list