Rob Shearman : rpcrt4: Fix -Oi interpreter for base types.
Alexandre Julliard
julliard at winehq.org
Mon Mar 10 17:05:10 CDT 2008
Module: wine
Branch: master
Commit: 259ccc573c1e8f03e6a46321f9b5cf76edf540d0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=259ccc573c1e8f03e6a46321f9b5cf76edf540d0
Author: Rob Shearman <rob at codeweavers.com>
Date: Mon Mar 10 17:05:59 2008 +0000
rpcrt4: Fix -Oi interpreter for base types.
Don't call memory sizing rountines to compute the size of a type, since
memory sizing routines have side effects like checking there is enough
space in the buffer for the type and incrementing the buffer pointer.
Instead, create a function which returns the necessary size of the
limited set of types we can encounter and remove call_memory_sizer which
is no longer needed.
---
dlls/rpcrt4/ndr_stubless.c | 61 ++++++++++++++++++++++++++------------------
1 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c
index 85c63d2..69347b2 100644
--- a/dlls/rpcrt4/ndr_stubless.c
+++ b/dlls/rpcrt4/ndr_stubless.c
@@ -91,29 +91,6 @@ static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemor
if (m) m(pStubMsg, pMemory, pFormat);
}
-static inline unsigned long call_memory_sizer(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
-{
- NDR_MEMORYSIZE m = NdrMemorySizer[pFormat[0] & NDR_TABLE_MASK];
- if (m)
- {
- unsigned char *saved_buffer = pStubMsg->Buffer;
- unsigned long ret;
- int saved_ignore_embedded_pointers = pStubMsg->IgnoreEmbeddedPointers;
- pStubMsg->MemorySize = 0;
- pStubMsg->IgnoreEmbeddedPointers = 1;
- ret = m(pStubMsg, pFormat);
- pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded_pointers;
- pStubMsg->Buffer = saved_buffer;
- return ret;
- }
- else
- {
- FIXME("format type 0x%x not implemented\n", pFormat[0]);
- RpcRaiseException(RPC_X_BAD_STUB_DATA);
- return 0;
- }
-}
-
#define STUBLESS_UNMARSHAL 1
#define STUBLESS_INITOUT 2
#define STUBLESS_CALLSERVER 3
@@ -426,6 +403,40 @@ static void client_do_args(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
}
}
+static unsigned int type_stack_size(unsigned char fc)
+{
+ switch (fc)
+ {
+ case RPC_FC_BYTE:
+ case RPC_FC_CHAR:
+ case RPC_FC_SMALL:
+ case RPC_FC_USMALL:
+ return sizeof(char);
+ case RPC_FC_WCHAR:
+ case RPC_FC_SHORT:
+ case RPC_FC_USHORT:
+ return sizeof(short);
+ case RPC_FC_LONG:
+ case RPC_FC_ULONG:
+ case RPC_FC_ENUM16:
+ case RPC_FC_ENUM32:
+ return sizeof(int);
+ case RPC_FC_FLOAT:
+ return sizeof(float);
+ case RPC_FC_DOUBLE:
+ return sizeof(double);
+ case RPC_FC_HYPER:
+ return sizeof(ULONGLONG);
+ case RPC_FC_ERROR_STATUS_T:
+ return sizeof(error_status_t);
+ case RPC_FC_IGNORE:
+ return sizeof(void *);
+ default:
+ ERR("invalid base type 0x%x\n", fc);
+ RpcRaiseException(RPC_S_INTERNAL_ERROR);
+ }
+}
+
static void client_do_args_old_format(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat, int phase, unsigned short stack_size,
unsigned char *pRetVal, BOOL object_proc)
@@ -491,7 +502,7 @@ static void client_do_args_old_format(PMIDL_STUB_MESSAGE pStubMsg,
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
- current_stack_offset += call_memory_sizer(pStubMsg, pTypeFormat);
+ current_stack_offset += type_stack_size(*pTypeFormat);
current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
}
else
@@ -1160,7 +1171,7 @@ static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
- current_stack_offset += call_memory_sizer(pStubMsg, pTypeFormat);
+ current_stack_offset += type_stack_size(*pTypeFormat);
current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
}
else
More information about the wine-cvs
mailing list