Release 970329
[wine/multimedia.git] / misc / ole2disp.c
blob69a08bfa21bdb779c45974942f16564cc0d767ef
1 /*
2 * OLE2DISP library
4 * Copyright 1995 Martin von Loewis
5 */
7 #include "windows.h"
8 #include "ole2.h"
9 #include "heap.h"
10 #include "ldt.h"
11 #include "stddebug.h"
12 #include "debug.h"
14 /* This implementation of the BSTR API is 16-bit only. It
15 represents BSTR as a 16:16 far pointer, and the strings
16 as ISO-8859 */
18 typedef DWORD BSTR;
20 static BSTR BSTR_AllocBytes(int n)
22 void *ptr = SEGPTR_ALLOC(n);
23 return SEGPTR_GET(ptr);
26 static void BSTR_Free(BSTR in)
28 SEGPTR_FREE( PTR_SEG_TO_LIN(in) );
31 static void* BSTR_GetAddr(BSTR in)
33 return in ? PTR_SEG_TO_LIN(in) : 0;
36 /***********************************************************************
37 * SysAllocString [OLE2DISP.2]
39 BSTR SysAllocString(char *in)
41 BSTR out=BSTR_AllocBytes(strlen(in)+1);
42 if(!out)return 0;
43 strcpy(BSTR_GetAddr(out),in);
44 return out;
47 /***********************************************************************
48 * SysReAllocString [OLE2DISP.3]
50 int SysReAllocString(BSTR *old,char *in)
52 BSTR new=SysAllocString(in);
53 BSTR_Free(*old);
54 *old=new;
55 return 1;
58 /***********************************************************************
59 * SysAllocStringLen [OLE2DISP.4]
61 BSTR SysAllocStringLen(char *in, int len)
63 BSTR out=BSTR_AllocBytes(len+1);
64 if(!out)return 0;
65 strcpy(BSTR_GetAddr(out),in);
66 return out;
69 /***********************************************************************
70 * SysReAllocStringLen [OLE2DISP.5]
72 int SysReAllocStringLen(BSTR *old,char *in,int len)
74 BSTR new=SysAllocStringLen(in,len);
75 BSTR_Free(*old);
76 *old=new;
77 return 1;
80 /***********************************************************************
81 * SysFreeString [OLE2DISP.6]
83 void SysFreeString(BSTR in)
85 BSTR_Free(in);
88 /***********************************************************************
89 * SysStringLen [OLE2DISP.7]
91 int SysStringLen(BSTR str)
93 return strlen(BSTR_GetAddr(str));