home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / rpc / dynout / dynoutp.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  1KB  |  35 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples.
  4. *       Copyright (C) 1995-1997 Microsoft Corporation.
  5. *       All rights reserved.
  6. *       This source code is only intended as a supplement to
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11. //
  12. // Sample code to show server-side
  13. // memory allocation for an [out] parameter
  14. //
  15. //
  16.  
  17. #include <assert.h>
  18. #include "stdio.h"
  19. #include "string.h"
  20. #include "dynout.h"
  21.  
  22. short GrabChunk(long *lSize, unsigned char **ppData)
  23. {
  24.     int cbChunk = rand() % 10000;    // how much memory to grab
  25.     int cChar = 33 + rand()%30;        // what to fill it with
  26.  
  27.     printf("GrabChunk() allocating %d bytes of '%c'\n",cbChunk,cChar);
  28.  
  29.     *lSize = (long)cbChunk;
  30.     *ppData = midl_user_allocate(cbChunk);
  31.     memset(*ppData,cChar,cbChunk);
  32.  
  33.     return 0;
  34. }
  35.