4 * Copyright 1995 Martin von Loewis
14 /* This implementation of the BSTR API is 16-bit only. It
15 represents BSTR as a 16:16 far pointer, and the strings
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 WINAPI SysAllocString(char *in)
41 BSTR out=BSTR_AllocBytes(strlen(in)+1);
43 strcpy(BSTR_GetAddr(out),in);
47 /***********************************************************************
48 * SysReAllocString [OLE2DISP.3]
50 int WINAPI SysReAllocString(BSTR *old,char *in)
52 BSTR new=SysAllocString(in);
58 /***********************************************************************
59 * SysAllocStringLen [OLE2DISP.4]
61 BSTR WINAPI SysAllocStringLen(char *in, int len)
63 BSTR out=BSTR_AllocBytes(len+1);
65 strcpy(BSTR_GetAddr(out),in);
69 /***********************************************************************
70 * SysReAllocStringLen [OLE2DISP.5]
72 int WINAPI SysReAllocStringLen(BSTR *old,char *in,int len)
74 BSTR new=SysAllocStringLen(in,len);
80 /***********************************************************************
81 * SysFreeString [OLE2DISP.6]
83 void WINAPI SysFreeString(BSTR in)
88 /***********************************************************************
89 * SysStringLen [OLE2DISP.7]
91 int WINAPI SysStringLen(BSTR str)
93 return strlen(BSTR_GetAddr(str));