remove use of GlobalAlloc() (bug 1885)

This commit is contained in:
Frank Warmerdam 2008-05-26 15:38:31 +00:00
parent eac1a5bc85
commit 27ebd800ef
2 changed files with 11 additions and 34 deletions

View File

@ -1,5 +1,9 @@
2008-05-26 Frank Warmerdam <warmerdam@pobox.com> 2008-05-26 Frank Warmerdam <warmerdam@pobox.com>
* libtiff/tif_win32.c: Replace custom Win32 memory api with generic
POSIX one. No apparent value to use of GlobalAlloc() in the modern
age. http://bugzilla.maptools.org/show_bug.cgi?id=1885
* libtiff/tiffconf.vc.h: Added JBIG_SUPPORT and MDI_SUPPORT items * libtiff/tiffconf.vc.h: Added JBIG_SUPPORT and MDI_SUPPORT items
in windows version (care of Edward Lam). in windows version (care of Edward Lam).

View File

@ -1,4 +1,4 @@
/* $Id: tif_win32.c,v 1.33 2008-01-01 15:35:54 fwarmerdam Exp $ */ /* $Id: tif_win32.c,v 1.34 2008-05-26 15:38:31 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -337,67 +337,40 @@ TIFFOpenW(const wchar_t* name, const char* mode)
#endif /* ndef _WIN32_WCE */ #endif /* ndef _WIN32_WCE */
void* void*
_TIFFmalloc(tmsize_t s) _TIFFmalloc(tmsize_t s)
{ {
return ((void*)GlobalAlloc(GMEM_FIXED, s)); return (malloc((size_t) s));
} }
void void
_TIFFfree(void* p) _TIFFfree(void* p)
{ {
GlobalFree((HGLOBAL)p); free(p);
return;
} }
void* void*
_TIFFrealloc(void* p, tmsize_t s) _TIFFrealloc(void* p, tmsize_t s)
{ {
void* pvTmp; return (realloc(p, (size_t) s));
tmsize_t old;
if(p == NULL)
return ((void*)GlobalAlloc(GMEM_FIXED, s));
old = (tmsize_t)GlobalSize(p);
if (old>=s) {
if ((pvTmp = (void*)GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, s);
GlobalFree((HGLOBAL)p);
}
} else {
if ((pvTmp = (void*)GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, old);
GlobalFree((HGLOBAL)p);
}
}
return (pvTmp);
} }
void void
_TIFFmemset(void* p, int v, tmsize_t c) _TIFFmemset(void* p, int v, tmsize_t c)
{ {
FillMemory(p, c, (BYTE)v); memset(p, v, (size_t) c);
} }
void void
_TIFFmemcpy(void* d, const void* s, tmsize_t c) _TIFFmemcpy(void* d, const void* s, tmsize_t c)
{ {
CopyMemory(d, s, c); memcpy(d, s, (size_t) c);
} }
int int
_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
{ {
register const BYTE *pb1 = (const BYTE *) p1; return (memcmp(p1, p2, (size_t) c));
register const BYTE *pb2 = (const BYTE *) p2;
register tmsize_t dwTmp = c;
register int iTmp;
for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (int)*pb1++ - (int)*pb2++)
;
return (iTmp);
} }
#ifndef _WIN32_WCE #ifndef _WIN32_WCE