src/render/SDL_d3dmath.h
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 29 Oct 2014 20:20:47 +0100
changeset 9201 21d9f9babb30
parent 8764 3d5ef7548688
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Fixed bug 2647 - Memory leak in SDL_AddHintCallback function - SDL_hints.c

Nitz

Variable entry going out of scope leaks the storage it points to, at:

/* Need to add a hint entry for this watcher */
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
if (!hint) {
return;
}

Patch is attached.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 #include "../SDL_internal.h"
    22 
    23 #if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
    24 
    25 /* Direct3D matrix math functions */
    26 
    27 typedef struct
    28 {
    29     float x;
    30     float y;
    31 } Float2;
    32 
    33 typedef struct
    34 {
    35     float x;
    36     float y;
    37     float z;
    38 } Float3;
    39 
    40 typedef struct
    41 {
    42     float x;
    43     float y;
    44     float z;
    45     float w;
    46 } Float4;
    47 
    48 typedef struct
    49 {
    50     union {
    51         struct {
    52             float _11, _12, _13, _14;
    53             float _21, _22, _23, _24;
    54             float _31, _32, _33, _34;
    55             float _41, _42, _43, _44;
    56         };
    57         float m[4][4];
    58     };
    59 } Float4X4;
    60 
    61 
    62 Float4X4 MatrixIdentity();
    63 Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
    64 Float4X4 MatrixScaling(float x, float y, float z);
    65 Float4X4 MatrixTranslation(float x, float y, float z);
    66 Float4X4 MatrixRotationX(float r);
    67 Float4X4 MatrixRotationY(float r);
    68 Float4X4 MatrixRotationZ(float r);
    69 
    70 #endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
    71 
    72 /* vi: set ts=4 sw=4 expandtab: */