Fix signed/unsigned comparison warnings.
[wine] / dlls / ole32 / ifs.c
1 /*
2  *      basic interfaces
3  *
4  *      Copyright 1997  Marcus Meissner
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <ctype.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <assert.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "ole2.h"
33 #include "winerror.h"
34
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(olemalloc);
38
39 /******************************************************************************
40  *      IMalloc32 implementation
41  *
42  * NOTES
43  *  For supporting CoRegisterMallocSpy the IMalloc implementation must know if
44  *  a given memory block was allocated with a spy active.
45  *
46  *****************************************************************************/
47 /* set the vtable later */
48 static IMallocVtbl VT_IMalloc32;
49
50 typedef struct {
51         IMallocVtbl *lpVtbl;
52         DWORD dummy;                /* nothing, we are static */
53         IMallocSpy * pSpy;          /* the spy when active */
54         DWORD SpyedAllocationsLeft; /* number of spyed allocations left */
55         BOOL SpyReleasePending;     /* CoRevokeMallocSpy called with spyed allocations left*/
56         LPVOID * SpyedBlocks;       /* root of the table */
57         int SpyedBlockTableLength;  /* size of the table*/
58 } _Malloc32;
59
60 /* this is the static object instance */
61 _Malloc32 Malloc32 = {&VT_IMalloc32, 0, NULL, 0, 0, NULL, 0};
62
63 /* with a spy active all calls from pre to post methods are threadsave */
64 static CRITICAL_SECTION IMalloc32_SpyCS;
65 static CRITICAL_SECTION_DEBUG critsect_debug =
66 {
67     0, 0, &IMalloc32_SpyCS,
68     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
69       0, 0, { 0, (DWORD)(__FILE__ ": IMalloc32_SpyCS") }
70 };
71 static CRITICAL_SECTION IMalloc32_SpyCS = { &critsect_debug, -1, 0, 0, 0, 0 };
72
73 /* resize the old table */
74 static int SetSpyedBlockTableLength ( int NewLength )
75 {
76         LPVOID *NewSpyedBlocks;
77
78         if (!Malloc32.SpyedBlocks) NewSpyedBlocks = LocalAlloc(GMEM_ZEROINIT, NewLength);
79         else NewSpyedBlocks = LocalReAlloc(Malloc32.SpyedBlocks, NewLength, GMEM_ZEROINIT);
80         if (NewSpyedBlocks) {
81                 Malloc32.SpyedBlocks = NewSpyedBlocks;
82                 Malloc32.SpyedBlockTableLength = NewLength;
83         }
84
85         return NewSpyedBlocks != NULL;
86 }
87
88 /* add a location to the table */
89 static int AddMemoryLocation(LPVOID * pMem)
90 {
91         LPVOID * Current;
92
93         /* allocate the table if not already allocated */
94         if (!Malloc32.SpyedBlockTableLength) {
95             if (!SetSpyedBlockTableLength(0x1000)) return 0;
96         }
97
98         /* find a free location */
99         Current = Malloc32.SpyedBlocks;
100         while (*Current) {
101             Current++;
102             if (Current >= Malloc32.SpyedBlocks + Malloc32.SpyedBlockTableLength) {
103                 /* no more space in table, grow it */
104                 if (!SetSpyedBlockTableLength( Malloc32.SpyedBlockTableLength + 0x1000 )) return 0;
105             }
106         };
107
108         /* put the location in our table */
109         *Current = pMem;
110         Malloc32.SpyedAllocationsLeft++;
111         /*TRACE("%lu\n",Malloc32.SpyedAllocationsLeft);*/
112         return 1;
113 }
114
115 static int RemoveMemoryLocation(LPVOID * pMem)
116 {
117         LPVOID * Current;
118
119         /* allocate the table if not already allocated */
120         if (!Malloc32.SpyedBlockTableLength) {
121             if (!SetSpyedBlockTableLength(0x1000)) return 0;
122         }
123
124         Current = Malloc32.SpyedBlocks;
125
126         /* find the location */
127         while (*Current != pMem) {
128             Current++;
129             if (Current >= Malloc32.SpyedBlocks + Malloc32.SpyedBlockTableLength)  return 0;      /* not found  */
130         }
131
132         /* location found */
133         Malloc32.SpyedAllocationsLeft--;
134         /*TRACE("%lu\n",Malloc32.SpyedAllocationsLeft);*/
135         *Current = NULL;
136         return 1;
137 }
138
139 /******************************************************************************
140  *      IMalloc32_QueryInterface        [VTABLE]
141  */
142 static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) {
143
144         TRACE("(%s,%p)\n",debugstr_guid(refiid),obj);
145
146         if (IsEqualIID(&IID_IUnknown,refiid) || IsEqualIID(&IID_IMalloc,refiid)) {
147                 *obj = (LPMALLOC)&Malloc32;
148                 return S_OK;
149         }
150         return E_NOINTERFACE;
151 }
152
153 /******************************************************************************
154  *      IMalloc32_AddRefRelease         [VTABLE]
155  */
156 static ULONG WINAPI IMalloc_fnAddRefRelease (LPMALLOC iface) {
157         return 1;
158 }
159
160 /******************************************************************************
161  *      IMalloc32_Alloc                 [VTABLE]
162  */
163 static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface, DWORD cb) {
164
165         LPVOID addr;
166
167         TRACE("(%ld)\n",cb);
168
169         if(Malloc32.pSpy) {
170             DWORD preAllocResult;
171             
172             EnterCriticalSection(&IMalloc32_SpyCS);
173             preAllocResult = IMallocSpy_PreAlloc(Malloc32.pSpy, cb);
174             if ((cb != 0) && (preAllocResult == 0)) {
175                 /* PreAlloc can force Alloc to fail, but not if cb == 0 */
176                 TRACE("returning null\n");
177                 LeaveCriticalSection(&IMalloc32_SpyCS);
178                 return NULL;
179             }
180         }
181         
182         addr = HeapAlloc(GetProcessHeap(),0,cb);
183
184         if(Malloc32.pSpy) {
185             addr = IMallocSpy_PostAlloc(Malloc32.pSpy, addr);
186             if (addr) AddMemoryLocation(addr);
187             LeaveCriticalSection(&IMalloc32_SpyCS);
188         }
189
190         TRACE("--(%p)\n",addr);
191         return addr;
192 }
193
194 /******************************************************************************
195  * IMalloc32_Realloc [VTABLE]
196  */
197 static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) {
198
199         LPVOID pNewMemory;
200
201         TRACE("(%p,%ld)\n",pv,cb);
202
203         if(Malloc32.pSpy) {
204             LPVOID pRealMemory;
205             BOOL fSpyed;
206
207             EnterCriticalSection(&IMalloc32_SpyCS);
208             fSpyed = RemoveMemoryLocation(pv);
209             cb = IMallocSpy_PreRealloc(Malloc32.pSpy, pv, cb, &pRealMemory, fSpyed);
210
211             /* check if can release the spy */
212             if(Malloc32.SpyReleasePending && !Malloc32.SpyedAllocationsLeft) {
213                 IMallocSpy_Release(Malloc32.pSpy);
214                 Malloc32.SpyReleasePending = FALSE;
215                 Malloc32.pSpy = NULL;
216             }
217
218             if (0==cb) {
219                 /* PreRealloc can force Realloc to fail */
220                 LeaveCriticalSection(&IMalloc32_SpyCS);
221                 return NULL;
222             }
223             pv = pRealMemory;
224         }
225
226         if (!pv) pNewMemory = HeapAlloc(GetProcessHeap(),0,cb);
227         else if (cb) pNewMemory = HeapReAlloc(GetProcessHeap(),0,pv,cb);
228         else {
229             HeapFree(GetProcessHeap(),0,pv);
230             pNewMemory = NULL;
231         }
232
233         if(Malloc32.pSpy) {
234             pNewMemory = IMallocSpy_PostRealloc(Malloc32.pSpy, pNewMemory, TRUE);
235             if (pNewMemory) AddMemoryLocation(pNewMemory);
236             LeaveCriticalSection(&IMalloc32_SpyCS);
237         }
238
239         TRACE("--(%p)\n",pNewMemory);
240         return pNewMemory;
241 }
242
243 /******************************************************************************
244  * IMalloc32_Free [VTABLE]
245  */
246 static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) {
247
248         BOOL fSpyed = 0;
249
250         TRACE("(%p)\n",pv);
251
252         if(Malloc32.pSpy) {
253             EnterCriticalSection(&IMalloc32_SpyCS);
254             fSpyed = RemoveMemoryLocation(pv);
255             pv = IMallocSpy_PreFree(Malloc32.pSpy, pv, fSpyed);
256         }
257
258         HeapFree(GetProcessHeap(),0,pv);
259
260         if(Malloc32.pSpy) {
261             IMallocSpy_PostFree(Malloc32.pSpy, fSpyed);
262
263             /* check if can release the spy */
264             if(Malloc32.SpyReleasePending && !Malloc32.SpyedAllocationsLeft) {
265                 IMallocSpy_Release(Malloc32.pSpy);
266                 Malloc32.SpyReleasePending = FALSE;
267                 Malloc32.pSpy = NULL;
268             }
269
270             LeaveCriticalSection(&IMalloc32_SpyCS);
271         }
272 }
273
274 /******************************************************************************
275  * IMalloc32_GetSize [VTABLE]
276  *
277  * NOTES
278  *  FIXME returns:
279  *      win95:  size allocated (4 byte boundarys)
280  *      win2k:  size originally requested !!! (allocated on 8 byte boundarys)
281  */
282 static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) {
283
284         DWORD cb;
285         BOOL fSpyed = 0;
286
287         TRACE("(%p)\n",pv);
288
289         if(Malloc32.pSpy) {
290             EnterCriticalSection(&IMalloc32_SpyCS);
291             pv = IMallocSpy_PreGetSize(Malloc32.pSpy, pv, fSpyed);
292         }
293
294         cb = HeapSize(GetProcessHeap(),0,pv);
295
296         if(Malloc32.pSpy) {
297             cb = IMallocSpy_PostGetSize(Malloc32.pSpy, cb, fSpyed);
298             LeaveCriticalSection(&IMalloc32_SpyCS);
299         }
300
301         return cb;
302 }
303
304 /******************************************************************************
305  * IMalloc32_DidAlloc [VTABLE]
306  */
307 static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) {
308
309         BOOL fSpyed = 0;
310         int didAlloc;
311
312         TRACE("(%p)\n",pv);
313
314         if(Malloc32.pSpy) {
315             EnterCriticalSection(&IMalloc32_SpyCS);
316             pv = IMallocSpy_PreDidAlloc(Malloc32.pSpy, pv, fSpyed);
317         }
318
319         didAlloc = -1;
320
321         if(Malloc32.pSpy) {
322             didAlloc = IMallocSpy_PostDidAlloc(Malloc32.pSpy, pv, fSpyed, didAlloc);
323             LeaveCriticalSection(&IMalloc32_SpyCS);
324         }
325         return didAlloc;
326 }
327
328 /******************************************************************************
329  * IMalloc32_HeapMinimize [VTABLE]
330  */
331 static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) {
332         TRACE("()\n");
333
334         if(Malloc32.pSpy) {
335             EnterCriticalSection(&IMalloc32_SpyCS);
336             IMallocSpy_PreHeapMinimize(Malloc32.pSpy);
337         }
338
339         if(Malloc32.pSpy) {
340             IMallocSpy_PostHeapMinimize(Malloc32.pSpy);
341             LeaveCriticalSection(&IMalloc32_SpyCS);
342         }
343 }
344
345 static IMallocVtbl VT_IMalloc32 =
346 {
347         IMalloc_fnQueryInterface,
348         IMalloc_fnAddRefRelease,
349         IMalloc_fnAddRefRelease,
350         IMalloc_fnAlloc,
351         IMalloc_fnRealloc,
352         IMalloc_fnFree,
353         IMalloc_fnGetSize,
354         IMalloc_fnDidAlloc,
355         IMalloc_fnHeapMinimize
356 };
357
358 /******************************************************************************
359  *      IMallocSpy implementation
360  *****************************************************************************/
361
362 /* set the vtable later */
363 static IMallocSpyVtbl VT_IMallocSpy;
364
365 typedef struct {
366         IMallocSpyVtbl *lpVtbl;
367         DWORD ref;
368 } _MallocSpy;
369
370 /* this is the static object instance */
371 _MallocSpy MallocSpy = {&VT_IMallocSpy, 0};
372
373 /******************************************************************************
374  *      IMalloc32_QueryInterface        [VTABLE]
375  */
376 static HRESULT WINAPI IMallocSpy_fnQueryInterface(LPMALLOCSPY iface,REFIID refiid,LPVOID *obj)
377 {
378
379         TRACE("(%s,%p)\n",debugstr_guid(refiid),obj);
380
381         if (IsEqualIID(&IID_IUnknown,refiid) || IsEqualIID(&IID_IMallocSpy,refiid)) {
382                 *obj = (LPMALLOC)&MallocSpy;
383                 return S_OK;
384         }
385         return E_NOINTERFACE;
386 }
387
388 /******************************************************************************
389  *      IMalloc32_AddRef                [VTABLE]
390  */
391 static ULONG WINAPI IMallocSpy_fnAddRef (LPMALLOCSPY iface)
392 {
393
394     _MallocSpy *This = (_MallocSpy *)iface;
395
396     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
397
398     return ++(This->ref);
399 }
400
401 /******************************************************************************
402  *      IMalloc32_AddRelease            [VTABLE]
403  *
404  * NOTES
405  *   Our MallocSpy is static. If the count reaches 0 we dump the leaks
406  */
407 static ULONG WINAPI IMallocSpy_fnRelease (LPMALLOCSPY iface)
408 {
409
410     _MallocSpy *This = (_MallocSpy *)iface;
411
412     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
413
414     if (!--(This->ref)) {
415         /* our allocation list MUST be empty here */
416     }
417     return This->ref;
418 }
419
420 static ULONG WINAPI IMallocSpy_fnPreAlloc(LPMALLOCSPY iface, ULONG cbRequest)
421 {
422     _MallocSpy *This = (_MallocSpy *)iface;
423     TRACE ("(%p)->(%lu)\n", This, cbRequest);
424     return cbRequest;
425 }
426 static PVOID WINAPI IMallocSpy_fnPostAlloc(LPMALLOCSPY iface, void* pActual)
427 {
428     _MallocSpy *This = (_MallocSpy *)iface;
429     TRACE ("(%p)->(%p)\n", This, pActual);
430     return pActual;
431 }
432
433 static PVOID WINAPI IMallocSpy_fnPreFree(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed)
434 {
435     _MallocSpy *This = (_MallocSpy *)iface;
436     TRACE ("(%p)->(%p %u)\n", This, pRequest, fSpyed);
437     return pRequest;
438 }
439 static void  WINAPI IMallocSpy_fnPostFree(LPMALLOCSPY iface, BOOL fSpyed)
440 {
441     _MallocSpy *This = (_MallocSpy *)iface;
442     TRACE ("(%p)->(%u)\n", This, fSpyed);
443 }
444
445 static ULONG WINAPI IMallocSpy_fnPreRealloc(LPMALLOCSPY iface, void* pRequest, ULONG cbRequest, void** ppNewRequest, BOOL fSpyed)
446 {
447     _MallocSpy *This = (_MallocSpy *)iface;
448     TRACE ("(%p)->(%p %lu %u)\n", This, pRequest, cbRequest, fSpyed);
449     *ppNewRequest = pRequest;
450     return cbRequest;
451 }
452
453 static PVOID WINAPI IMallocSpy_fnPostRealloc(LPMALLOCSPY iface, void* pActual, BOOL fSpyed)
454 {
455     _MallocSpy *This = (_MallocSpy *)iface;
456     TRACE ("(%p)->(%p %u)\n", This, pActual, fSpyed);
457     return pActual;
458 }
459
460 static PVOID WINAPI IMallocSpy_fnPreGetSize(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed)
461 {
462     _MallocSpy *This = (_MallocSpy *)iface;
463     TRACE ("(%p)->(%p %u)\n", This,  pRequest, fSpyed);
464     return pRequest;
465 }
466
467 static ULONG WINAPI IMallocSpy_fnPostGetSize(LPMALLOCSPY iface, ULONG cbActual, BOOL fSpyed)
468 {
469     _MallocSpy *This = (_MallocSpy *)iface;
470     TRACE ("(%p)->(%lu %u)\n", This, cbActual, fSpyed);
471     return cbActual;
472 }
473
474 static PVOID WINAPI IMallocSpy_fnPreDidAlloc(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed)
475 {
476     _MallocSpy *This = (_MallocSpy *)iface;
477     TRACE ("(%p)->(%p %u)\n", This, pRequest, fSpyed);
478     return pRequest;
479 }
480
481 static int WINAPI IMallocSpy_fnPostDidAlloc(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed, int fActual)
482 {
483     _MallocSpy *This = (_MallocSpy *)iface;
484     TRACE ("(%p)->(%p %u %u)\n", This, pRequest, fSpyed, fActual);
485     return fActual;
486 }
487
488 static void WINAPI IMallocSpy_fnPreHeapMinimize(LPMALLOCSPY iface)
489 {
490     _MallocSpy *This = (_MallocSpy *)iface;
491     TRACE ("(%p)->()\n", This);
492 }
493
494 static void WINAPI IMallocSpy_fnPostHeapMinimize(LPMALLOCSPY iface)
495 {
496     _MallocSpy *This = (_MallocSpy *)iface;
497     TRACE ("(%p)->()\n", This);
498 }
499
500 static void MallocSpyDumpLeaks() {
501         TRACE("leaks: %lu\n", Malloc32.SpyedAllocationsLeft);
502 }
503
504 static IMallocSpyVtbl VT_IMallocSpy =
505 {
506         IMallocSpy_fnQueryInterface,
507         IMallocSpy_fnAddRef,
508         IMallocSpy_fnRelease,
509         IMallocSpy_fnPreAlloc,
510         IMallocSpy_fnPostAlloc,
511         IMallocSpy_fnPreFree,
512         IMallocSpy_fnPostFree,
513         IMallocSpy_fnPreRealloc,
514         IMallocSpy_fnPostRealloc,
515         IMallocSpy_fnPreGetSize,
516         IMallocSpy_fnPostGetSize,
517         IMallocSpy_fnPreDidAlloc,
518         IMallocSpy_fnPostDidAlloc,
519         IMallocSpy_fnPreHeapMinimize,
520         IMallocSpy_fnPostHeapMinimize
521 };
522
523 /******************************************************************************
524  *              CoGetMalloc     [OLE32.@]
525  *
526  * RETURNS
527  *      The win32 IMalloc
528  */
529 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC *lpMalloc)
530 {
531         *lpMalloc = (LPMALLOC)&Malloc32;
532         return S_OK;
533 }
534
535 /***********************************************************************
536  *           CoTaskMemAlloc     [OLE32.@]
537  * RETURNS
538  *      pointer to newly allocated block
539  */
540 LPVOID WINAPI CoTaskMemAlloc(ULONG size)
541 {
542         return IMalloc_Alloc((LPMALLOC)&Malloc32,size);
543 }
544 /***********************************************************************
545  *           CoTaskMemFree      [OLE32.@]
546  */
547 VOID WINAPI CoTaskMemFree(LPVOID ptr)
548 {
549         IMalloc_Free((LPMALLOC)&Malloc32, ptr);
550 }
551
552 /***********************************************************************
553  *           CoTaskMemRealloc   [OLE32.@]
554  * RETURNS
555  *      pointer to newly allocated block
556  */
557 LPVOID WINAPI CoTaskMemRealloc(LPVOID pvOld, ULONG size)
558 {
559         return IMalloc_Realloc((LPMALLOC)&Malloc32, pvOld, size);
560 }
561
562 /***********************************************************************
563  *           CoRegisterMallocSpy        [OLE32.@]
564  *
565  * NOTES
566  *  if a mallocspy is already registered, we can't do it again since
567  *  only the spy knows, how to free a memory block
568  */
569 HRESULT WINAPI CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy)
570 {
571         IMallocSpy* pSpy;
572         HRESULT hres = E_INVALIDARG;
573
574         TRACE("\n");
575
576         /* HACK TO ACTIVATE OUT SPY */
577         if (pMallocSpy == (LPVOID)-1) pMallocSpy =(IMallocSpy*)&MallocSpy;
578
579         if(Malloc32.pSpy) return CO_E_OBJISREG;
580
581         EnterCriticalSection(&IMalloc32_SpyCS);
582
583         if (SUCCEEDED(IUnknown_QueryInterface(pMallocSpy, &IID_IMallocSpy, (LPVOID*)&pSpy))) {
584             Malloc32.pSpy = pSpy;
585             hres = S_OK;
586         }
587
588         LeaveCriticalSection(&IMalloc32_SpyCS);
589
590         return hres;
591 }
592
593 /***********************************************************************
594  *           CoRevokeMallocSpy  [OLE32.@]
595  *
596  * NOTES
597  *  we can't revoke a malloc spy as long as memory blocks allocated with
598  *  the spy are active since only the spy knows how to free them
599  */
600 HRESULT WINAPI CoRevokeMallocSpy(void)
601 {
602         HRESULT hres = S_OK;
603         TRACE("\n");
604
605         EnterCriticalSection(&IMalloc32_SpyCS);
606
607         /* if it's our spy it's time to dump the leaks */
608         if (Malloc32.pSpy == (IMallocSpy*)&MallocSpy) {
609             MallocSpyDumpLeaks();
610         }
611
612         if (Malloc32.SpyedAllocationsLeft) {
613             TRACE("SpyReleasePending with %lu allocations left\n", Malloc32.SpyedAllocationsLeft);
614             Malloc32.SpyReleasePending = TRUE;
615             hres = E_ACCESSDENIED;
616         } else {
617             IMallocSpy_Release(Malloc32.pSpy);
618             Malloc32.pSpy = NULL;
619         }
620         LeaveCriticalSection(&IMalloc32_SpyCS);
621
622         return S_OK;
623 }
624
625 /******************************************************************************
626  *              IsValidInterface        [OLE32.@]
627  *
628  * RETURNS
629  *  True, if the passed pointer is a valid interface
630  */
631 BOOL WINAPI IsValidInterface(
632         LPUNKNOWN punk  /* [in] interface to be tested */
633 ) {
634         return !(
635                 IsBadReadPtr(punk,4)                                    ||
636                 IsBadReadPtr(punk->lpVtbl,4)                            ||
637                 IsBadReadPtr(punk->lpVtbl->QueryInterface,9)    ||
638                 IsBadCodePtr((FARPROC)punk->lpVtbl->QueryInterface)
639         );
640 }