Author: khornicek Date: Wed Sep 30 14:59:06 2009 New Revision: 43233
URL: http://svn.reactos.org/svn/reactos?rev=43233&view=rev Log: - simplify the code a bit
Modified: trunk/reactos/dll/win32/opengl32/font.c
Modified: trunk/reactos/dll/win32/opengl32/font.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/opengl32/font.c?r... ============================================================================== --- trunk/reactos/dll/win32/opengl32/font.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/opengl32/font.c [iso-8859-1] Wed Sep 30 14:59:06 2009 @@ -36,39 +36,6 @@ static DWORD VertBufIndex; static GLenum TessErrorOccurred;
- -/***************************************************************************** -* InitLineBuf -* -* Initializes the global LineBuf and its associated size and current-element -* counters. -*****************************************************************************/ - -INT InitLineBuf(VOID) -{ - if (!(LineBuf = (FLOAT*) - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (LineBufSize = LINE_BUF_QUANT) * sizeof(FLOAT)))) - return 0; - LineBufIndex = 0; - return 1; -} - -/***************************************************************************** -* InitVertBuf -* -* Initializes the global VertBuf and its associated size and current-element -* counters. -*****************************************************************************/ - -INT InitVertBuf(VOID) -{ - if (!(VertBuf = (FLOAT*) - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (VertBufSize = VERT_BUF_QUANT) * sizeof(FLOAT)))) - return 0; - VertBufIndex = 0; - return 1; -} - /***************************************************************************** * AppendToLineBuf * @@ -81,8 +48,9 @@ if (LineBufIndex >= LineBufSize) { FLOAT* f; - - f = (FLOAT*) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, LineBuf, (LineBufSize += LINE_BUF_QUANT) * sizeof(FLOAT)); + LineBufSize += LINE_BUF_QUANT; + + f = (FLOAT*) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, LineBuf, (LineBufSize) * sizeof(FLOAT)); if (!f) return 0; LineBuf = f; @@ -107,36 +75,6 @@ return 0; VertBuf[VertBufIndex++] = value; return 1; -} - -/***************************************************************************** -* FreeLineBuf -* -* Cleans up vertex buffer structure. -*****************************************************************************/ - -VOID FreeLineBuf(VOID) -{ - if (LineBuf) - { - HeapFree(GetProcessHeap(), 0, LineBuf); - LineBuf = NULL; - } -} - -/***************************************************************************** -* FreeVertBuf -* -* Cleans up vertex buffer structure. -*****************************************************************************/ - -VOID FreeVertBuf(VOID) -{ - if (VertBuf) - { - HeapFree(GetProcessHeap(), 0, VertBuf); - VertBuf = NULL; - } }
/***************************************************************************** @@ -634,8 +572,13 @@ /* * Initialize the global buffer into which we place the outlines: */ - if (!InitLineBuf()) + LineBuf = (FLOAT*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (LINE_BUF_QUANT) * sizeof(FLOAT)); + + if(!LineBuf) goto exit; + + LineBufSize = LINE_BUF_QUANT; + LineBufIndex = 0;
/* * Convert the glyph outlines to a set of polyline loops. @@ -681,8 +624,14 @@ * auxiliary routines for drawing. */
- if (!InitVertBuf()) + VertBuf = (FLOAT*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (VERT_BUF_QUANT) * sizeof(FLOAT)); + + if (!VertBuf) goto exit; + + VertBufSize = VERT_BUF_QUANT; + VertBufIndex = 0; + if (!(tess = gluNewTess())) goto exit;
@@ -799,11 +748,16 @@
exit: - FreeLineBuf(); + + if(LineBuf) + HeapFree(GetProcessHeap(), 0, LineBuf); + + if(VertBuf) + HeapFree(GetProcessHeap(), 0, VertBuf); + if (tess) gluDeleteTess(tess);
- FreeVertBuf(); return status; }