Fixed Visual Studio compilation problems
authorSam Lantinga <slouken@libsdl.org>
Tue, 26 Aug 2008 07:34:49 +0000
changeset 27282768bd7281e0
parent 2727 76c2fc9696ea
child 2729 6c8bc4d87282
Fixed Visual Studio compilation problems
src/audio/SDL_audio.c
src/audio/SDL_audiocvt.c
src/video/win32/SDL_win32mouse.c
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32video.h
src/video/win32/SDL_win32window.c
     1.1 --- a/src/audio/SDL_audio.c	Tue Aug 26 07:34:23 2008 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Tue Aug 26 07:34:49 2008 +0000
     1.3 @@ -291,10 +291,8 @@
     1.4  int
     1.5  SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
     1.6  {
     1.7 -    int i;
     1.8 -
     1.9      /* First try to allocate the buffer */
    1.10 -    stream->buffer = (Uint8 *) malloc(max_len);
    1.11 +    stream->buffer = (Uint8 *) SDL_malloc(max_len);
    1.12      if (stream->buffer == NULL) {
    1.13          return -1;
    1.14      }
    1.15 @@ -304,9 +302,9 @@
    1.16      stream->write_pos = 0;
    1.17  
    1.18      /* Zero out the buffer */
    1.19 -    for (i = 0; i < max_len; ++i) {
    1.20 -        stream->buffer[i] = silence;
    1.21 -    }
    1.22 +    SDL_memset(stream->buffer, silence, max_len);
    1.23 +
    1.24 +    return 0;
    1.25  }
    1.26  
    1.27  /* Deinitialize the stream simply by freeing the buffer */
    1.28 @@ -314,7 +312,7 @@
    1.29  SDL_StreamDeinit(SDL_AudioStreamer * stream)
    1.30  {
    1.31      if (stream->buffer != NULL) {
    1.32 -        free(stream->buffer);
    1.33 +        SDL_free(stream->buffer);
    1.34      }
    1.35  }
    1.36  
     2.1 --- a/src/audio/SDL_audiocvt.c	Tue Aug 26 07:34:23 2008 +0000
     2.2 +++ b/src/audio/SDL_audiocvt.c	Tue Aug 26 07:34:49 2008 +0000
     2.3 @@ -20,6 +20,8 @@
     2.4      slouken@libsdl.org
     2.5  */
     2.6  #include "SDL_config.h"
     2.7 +
     2.8 +#define _USE_MATH_DEFINES
     2.9  #include <math.h>
    2.10  
    2.11  /* Functions for audio drivers to perform runtime conversion of audio format */
    2.12 @@ -27,7 +29,7 @@
    2.13  #include "SDL_audio.h"
    2.14  #include "SDL_audio_c.h"
    2.15  
    2.16 -#define DEBUG_CONVERT
    2.17 +//#define DEBUG_CONVERT
    2.18  
    2.19  /* These are fractional multiplication routines. That is, their inputs
    2.20     are two numbers in the range [-1, 1) and the result falls in that
    2.21 @@ -1369,7 +1371,7 @@
    2.22  
    2.23      w0 = 2.0f * M_PI * fc;
    2.24      cosw0 = cosf(w0);
    2.25 -    alpha = sin(w0) / (2.0f * Q);
    2.26 +    alpha = sinf(w0) / (2.0f * Q);
    2.27  
    2.28      /* Compute coefficients, normalizing by a0 */
    2.29      scale = 1.0f / (1.0f + alpha);
    2.30 @@ -1438,7 +1440,7 @@
    2.31  #endif
    2.32  
    2.33      /* Initialize the state buffer to all zeroes, and set initial position */
    2.34 -    memset(cvt->state_buf, 0, 4 * SDL_AUDIO_BITSIZE(format) / 4);
    2.35 +    SDL_memset(cvt->state_buf, 0, 4 * SDL_AUDIO_BITSIZE(format) / 4);
    2.36      cvt->state_pos = 0;
    2.37  #undef convert_fixed
    2.38  }
    2.39 @@ -1636,7 +1638,7 @@
    2.40      cvt->len_sinc = m + 1;
    2.41  
    2.42      /* Allocate the floating point windowed sinc. */
    2.43 -    fSinc = (float *) malloc((m + 1) * sizeof(float));
    2.44 +    fSinc = SDL_stack_alloc(float, (m + 1));
    2.45      if (fSinc == NULL) {
    2.46          return -1;
    2.47      }
    2.48 @@ -1699,16 +1701,17 @@
    2.49      }
    2.50  
    2.51      /* Initialize the state buffer to all zeroes, and set initial position */
    2.52 -    memset(cvt->state_buf, 0, cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4);
    2.53 +    SDL_memset(cvt->state_buf, 0,
    2.54 +               cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4);
    2.55      cvt->state_pos = 0;
    2.56  
    2.57      /* Clean up */
    2.58  #undef convert_fixed
    2.59 -    free(fSinc);
    2.60 +    SDL_stack_free(fSinc);
    2.61  }
    2.62  
    2.63  /* This is used to reduce the resampling ratio */
    2.64 -inline int
    2.65 +static __inline__ int
    2.66  SDL_GCD(int a, int b)
    2.67  {
    2.68      int temp;
     3.1 --- a/src/video/win32/SDL_win32mouse.c	Tue Aug 26 07:34:23 2008 +0000
     3.2 +++ b/src/video/win32/SDL_win32mouse.c	Tue Aug 26 07:34:49 2008 +0000
     3.3 @@ -173,8 +173,8 @@
     3.4          if (tablet == index) {
     3.5              AXIS pressure;
     3.6              int cursors;
     3.7 -            data->WTInfo(WTI_DEVICES, DVC_NPRESSURE, &pressure);
     3.8 -            data->WTInfo(WTI_DEVICES, DVC_NCSRTYPES, &cursors);
     3.9 +            data->WTInfoA(WTI_DEVICES, DVC_NPRESSURE, &pressure);
    3.10 +            data->WTInfoA(WTI_DEVICES, DVC_NCSRTYPES, &cursors);
    3.11              data->mouse =
    3.12                  SDL_AddMouse(&mouse, index, device_name, pressure.axMax,
    3.13                               pressure.axMin, cursors);
     4.1 --- a/src/video/win32/SDL_win32video.c	Tue Aug 26 07:34:23 2008 +0000
     4.2 +++ b/src/video/win32/SDL_win32video.c	Tue Aug 26 07:34:49 2008 +0000
     4.3 @@ -110,14 +110,14 @@
     4.4      data->wintabDLL = LoadLibrary(TEXT("WINTAB32.DLL"));
     4.5      if (data->wintabDLL) {
     4.6  #define PROCNAME(X) #X
     4.7 -        data->WTInfo =
     4.8 +        data->WTInfoA =
     4.9              (UINT(*)(UINT, UINT, LPVOID)) GetProcAddress(data->wintabDLL,
    4.10 -                                                         PROCNAME(WTInfo));
    4.11 -        data->WTOpen =
    4.12 -            (HCTX(*)(HWND, LPLOGCONTEXT, BOOL)) GetProcAddress(data->
    4.13 -                                                               wintabDLL,
    4.14 -                                                               PROCNAME
    4.15 -                                                               (WTOpen));
    4.16 +                                                         PROCNAME(WTInfoA));
    4.17 +        data->WTOpenA =
    4.18 +            (HCTX(*)(HWND, LPLOGCONTEXTA, BOOL)) GetProcAddress(data->
    4.19 +                                                                wintabDLL,
    4.20 +                                                                PROCNAME
    4.21 +                                                                (WTOpenA));
    4.22          data->WTPacket =
    4.23              (int (*)(HCTX, UINT, LPVOID)) GetProcAddress(data->wintabDLL,
    4.24                                                           PROCNAME(WTPacket));
    4.25 @@ -126,7 +126,7 @@
    4.26                                             PROCNAME(WTClose));
    4.27  #undef PROCNAME
    4.28  
    4.29 -        if (!data->WTInfo || !data->WTOpen || !data->WTPacket
    4.30 +        if (!data->WTInfoA || !data->WTOpenA || !data->WTPacket
    4.31              || !data->WTClose) {
    4.32              FreeLibrary(data->wintabDLL);
    4.33              data->wintabDLL = NULL;
     5.1 --- a/src/video/win32/SDL_win32video.h	Tue Aug 26 07:34:23 2008 +0000
     5.2 +++ b/src/video/win32/SDL_win32video.h	Tue Aug 26 07:34:49 2008 +0000
     5.3 @@ -69,8 +69,8 @@
     5.4  /* *INDENT-OFF* */
     5.5      /* Function pointers for the Wacom API */
     5.6      HANDLE wintabDLL;
     5.7 -    UINT (*WTInfo) (UINT, UINT, LPVOID);
     5.8 -    HCTX (*WTOpen) (HWND, LPLOGCONTEXT, BOOL);
     5.9 +    UINT (*WTInfoA) (UINT, UINT, LPVOID);
    5.10 +    HCTX (*WTOpenA) (HWND, LPLOGCONTEXTA, BOOL);
    5.11      int (*WTPacket) (HCTX, UINT, LPVOID);
    5.12      BOOL (*WTClose) (HCTX);
    5.13  /* *INDENT-ON* */
     6.1 --- a/src/video/win32/SDL_win32window.c	Tue Aug 26 07:34:23 2008 +0000
     6.2 +++ b/src/video/win32/SDL_win32window.c	Tue Aug 26 07:34:49 2008 +0000
     6.3 @@ -151,7 +151,7 @@
     6.4      SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     6.5      RAWINPUTDEVICE Rid;
     6.6      AXIS TabX, TabY;
     6.7 -    LOGCONTEXT lc;
     6.8 +    LOGCONTEXTA lc;
     6.9      HWND hwnd;
    6.10      HWND top;
    6.11      RECT rect;
    6.12 @@ -206,15 +206,16 @@
    6.13      }
    6.14  
    6.15      /* we're configuring the tablet data. See Wintab reference for more info */
    6.16 -    if (videodata->wintabDLL && videodata->WTInfo(WTI_DEFSYSCTX, 0, &lc) != 0) {
    6.17 +    if (videodata->wintabDLL
    6.18 +        && videodata->WTInfoA(WTI_DEFSYSCTX, 0, &lc) != 0) {
    6.19          lc.lcPktData = PACKETDATA;
    6.20          lc.lcPktMode = PACKETMODE;
    6.21          lc.lcOptions |= CXO_MESSAGES;
    6.22          lc.lcOptions |= CXO_SYSTEM;
    6.23          lc.lcMoveMask = PACKETDATA;
    6.24          lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA;
    6.25 -        videodata->WTInfo(WTI_DEVICES, DVC_X, &TabX);
    6.26 -        videodata->WTInfo(WTI_DEVICES, DVC_Y, &TabY);
    6.27 +        videodata->WTInfoA(WTI_DEVICES, DVC_X, &TabX);
    6.28 +        videodata->WTInfoA(WTI_DEVICES, DVC_Y, &TabY);
    6.29          lc.lcInOrgX = 0;
    6.30          lc.lcInOrgY = 0;
    6.31          lc.lcInExtX = TabX.axMax;
    6.32 @@ -235,7 +236,7 @@
    6.33              }
    6.34              g_hCtx = tmp_hctx;
    6.35          }
    6.36 -        g_hCtx[window->id] = videodata->WTOpen(hwnd, &lc, TRUE);
    6.37 +        g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE);
    6.38      }
    6.39  
    6.40      /* we're telling the window, we want it to report raw input events from mice */