home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / msdos / programm / 8192 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.6 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!nuscc!iti.gov.sg!teechong
  2. From: teechong@iti.gov.sg (Lee Tee Chong)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Porting of UNIX code to Windows poser
  5. Summary: malloc and GlobalAlloc execution caused es register to change to 0000
  6. Keywords: memory allocation
  7. Message-ID: <1992Jul31.024020.18529@iti.gov.sg>
  8. Date: 31 Jul 92 02:40:20 GMT
  9. Sender: news@iti.gov.sg (News Admin)
  10. Organization: Information Technology Institute, National Computer Board, S'pore
  11. Lines: 21
  12.  
  13. I'm trying to port some UNIX codes that are written for TIFF i/o (including compression and decompression routines) over to the PC environment to run under Windows using Borland C version 3.0. 
  14.  
  15. I try not to change anything except throwing #ifdef statements to handle environment-specific features. All functions are changed to ANSI C functions, like fopen, fread, fwrite, etc. 
  16.  
  17. Where the memory allocation function is concern, I #undef malloc if WINDOWS is defined and #define it to my own function where I use GlobalAlloc and GlobalLock while returning a LPSTR. I also maintain the handles to the global memory (HANDLE hGMem) that is returned from GlobalAlloc in a simple list which associates the hGMem with the pointer returned from GlobalLock. 
  18.  
  19. When I use Borland's TDW to trace the code and examine the registers, I noticed that the es register changed some value like "es: 2D2F" to "es: 0000" when the GlobalAlloc statement is executed. This did not crash me out immediately but caused some code to fail later (Exception 13 code 0) whenever the es register is used.
  20.  
  21. Does anyone have had a similar experience before? What could be the problem? Is there a better/easier way to port memory allocation functions to Windows? I understand that malloc translate to LocalAlloc with LMEM_FIXED under Windows, which is why I'm using the above method- I need to allocate fairly big chunks. I need help urgently. Thanks. 
  22.  
  23. -------------                                 -----------------------------
  24. LEE TEE CHONG                                 Internet: teechong@iti.gov.sg
  25. Computer and Communications Lab               Bitnet  : TEECHONG@ITIVAX
  26. Information Technology Institute              Tel (O) :(65)-7720955
  27. National Computer Board                       -----------------------------
  28. 71, Science Park Drive, Singapore (0511)      -----------------------------
  29. -- 
  30. -------------                                 -----------------------------
  31. LEE TEE CHONG                                 Internet: teechong@iti.gov.sg
  32. Computer and Communications Lab               Bitnet  : TEECHONG@ITIVAX
  33. Information Technology Institute              Tel (O) :(65)-7720955
  34.