aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-09-01 11:59:51 +0000
committerSimon Tatham <anakin@pobox.com>2005-09-01 11:59:51 +0000
commit04e26aaa7b04af90d8d42e77d3d9ccc1dade678c (patch)
treea7f73f2565c8c699e14850c96585e1a8dafa56df
parent94b36c11e00bb740813506b0d3911f90f1829941 (diff)
downloadpuzzles-04e26aaa7b04af90d8d42e77d3d9ccc1dade678c.zip
puzzles-04e26aaa7b04af90d8d42e77d3d9ccc1dade678c.tar.gz
puzzles-04e26aaa7b04af90d8d42e77d3d9ccc1dade678c.tar.bz2
puzzles-04e26aaa7b04af90d8d42e77d3d9ccc1dade678c.tar.xz
James H's memory leak fixes to Inertia.
[originally from svn r6255]
-rw-r--r--inertia.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/inertia.c b/inertia.c
index fc213da..95bdcc8 100644
--- a/inertia.c
+++ b/inertia.c
@@ -221,6 +221,9 @@ static struct solver_scratch *new_scratch(int w, int h)
static void free_scratch(struct solver_scratch *sc)
{
+ sfree(sc->reachable_from);
+ sfree(sc->reachable_to);
+ sfree(sc->positions);
sfree(sc);
}
@@ -940,6 +943,8 @@ static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
static void game_free_drawstate(drawing *dr, game_drawstate *ds)
{
+ if (ds->player_background)
+ blitter_free(dr, ds->player_background);
sfree(ds->grid);
sfree(ds);
}
span>; v[2] = 0; } vec3::vec3(scalar x) { v[0] = x; v[1] = 0; v[2] = 0; } vec3::vec3(scalar x, scalar y, scalar z) { v[0] = x; v[1] = y; v[2] = z; } scalar &vec3::operator[](int index) { return v[index]; } scalar vec3::operator[](int index) const { return v[index]; } vec3 vec3::operator*(scalar scale) const { return vec3(v[0] * scale, v[1] * scale, v[2] * scale); } vec3 vec3::operator/(scalar scale) const { return vec3(v[0] / scale, v[1] / scale, v[2] / scale); } vec3 vec3::operator+(const vec3 &other) const{ return vec3(v[0] + other.v[0], v[1] + other.v[1], v[2] + other.v[2]); } vec3 vec3::operator-(const vec3 &other) const { return vec3(v[0] - other.v[0], v[1] - other.v[1], v[2] - other.v[2]); } vec3 vec3::operator-() const { return vec3(-v[0], -v[1], -v[2]); } const vec3 &vec3::operator*=(scalar scale) { v[0] *= scale; v[1] *= scale; v[2] *= scale; return *this; } const vec3 &vec3::operator/=(scalar scale) { v[0] /= scale; v[1] /= scale; v[2] /= scale; return *this; } const vec3 &vec3::operator+=(const vec3 &other) { v[0] += other.v[0]; v[1] += other.v[1]; v[2] += other.v[2]; return *this; } const vec3 &vec3::operator-=(const vec3 &other) { v[0] -= other.v[0]; v[1] -= other.v[1]; v[2] -= other.v[2]; return *this; } scalar vec3::magnitude() const { return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); } scalar vec3::magnitudeSquared() const { return v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; } vec3 vec3::normalize() const { scalar m = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); return vec3(v[0] / m, v[1] / m, v[2] / m); } scalar vec3::dot(const vec3 &other) const { return v[0] * other.v[0] + v[1] * other.v[1] + v[2] * other.v[2]; } vec3 vec3::cross(const vec3 &other) const { return vec3(v[1] * other.v[2] - v[2] * other.v[1], v[2] * other.v[0] - v[0] * other.v[2], v[0] * other.v[1] - v[1] * other.v[0]); } std::ostream &operator<<(std::ostream &output, const vec3 &v) { return output << v[0] << " " << v[1] << " " << v[2]; } std::istream &operator>>(std::istream &input, vec3 &v) { if(!(input >> v[0] >> v[1] >> v[2])) throw "error parsing vector"; return input; } vec3 operator*(scalar scale, const vec3 &v) { return v * scale; } vec3 vec3::rotateby(const quat &rotquat) const { return rotquat * (*this) * rotquat.conjugate(); } #define EPS 1e-5 #define ISZERO(a) ((fabs((a)) < EPS)) vec3 vec3::any_unit_normal(const vec3 &v) { if(ISZERO(v[0]) && ISZERO(v[1])) return vec3(1, 0, 0); return vec3(-v[1], v[0], 0).normalize(); } }