Fix a load of memory leaks
Also fix some compiler warnings (missing headers, wrong pointer type for modf, etc) and move variable declarations for Visual Studio.
This commit is contained in:
parent
7ae52660f5
commit
93316a9f1d
@ -836,7 +836,7 @@ static wall_type wtypes[] =
|
|||||||
{PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, "Gravity wall"},
|
{PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, "Gravity wall"},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CHANNELS ((int)(MAX_TEMP-73.15f)/100+2)
|
#define CHANNELS ((int)(MAX_TEMP-73)/100+2)
|
||||||
particle portalp[CHANNELS][8][80];
|
particle portalp[CHANNELS][8][80];
|
||||||
const particle emptyparticle;
|
const particle emptyparticle;
|
||||||
int wireless[CHANNELS][2];
|
int wireless[CHANNELS][2];
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <powder.h>
|
#include <powder.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
char pyready=1;
|
char pyready=1;
|
||||||
char pygood=1;
|
char pygood=1;
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
#include <element.h>
|
#include <element.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(__GNUC__)
|
int create_n_parts(int n, int x, int y, float vx, float vy, float temp, int t)//testing a new deut create part
|
||||||
_inline int create_n_parts(int n, int x, int y, float vx, float vy, float temp, int t)
|
|
||||||
#else
|
|
||||||
inline int create_n_parts(int n, int x, int y, float vx, float vy, float temp, int t)//testing a new deut create part
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
int i, c;
|
int i, c;
|
||||||
n = (n/50);
|
n = (n/50);
|
||||||
|
@ -186,13 +186,13 @@ int update_SOAP(UPDATE_FUNC_ARGS)
|
|||||||
|
|
||||||
if ((r&0xFF) == PT_OIL)
|
if ((r&0xFF) == PT_OIL)
|
||||||
{
|
{
|
||||||
|
float ax, ay;
|
||||||
|
|
||||||
parts[i].vy -= 0.1f;
|
parts[i].vy -= 0.1f;
|
||||||
|
|
||||||
parts[i].vy *= 0.5f;
|
parts[i].vy *= 0.5f;
|
||||||
parts[i].vx *= 0.5f;
|
parts[i].vx *= 0.5f;
|
||||||
|
|
||||||
float ax, ay;
|
|
||||||
|
|
||||||
ax = (parts[i].vx + parts[r>>8].vx)/2;
|
ax = (parts[i].vx + parts[r>>8].vx)/2;
|
||||||
ay = (parts[i].vy + parts[r>>8].vy)/2;
|
ay = (parts[i].vy + parts[r>>8].vy)/2;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ int update_STKM(UPDATE_FUNC_ARGS) {
|
|||||||
|
|
||||||
//Go left
|
//Go left
|
||||||
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
||||||
if (((int)(player[0])&0x01) == 0x01 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
if (((int)(player[0])&0x01) == 0x01 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
||||||
{
|
{
|
||||||
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
||||||
&& (r&0xFF) != PT_LNTG))
|
&& (r&0xFF) != PT_LNTG))
|
||||||
@ -125,7 +125,7 @@ int update_STKM(UPDATE_FUNC_ARGS) {
|
|||||||
|
|
||||||
//Go right
|
//Go right
|
||||||
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
||||||
if (((int)(player[0])&0x02) == 0x02 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
if (((int)(player[0])&0x02) == 0x02 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
||||||
{
|
{
|
||||||
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
||||||
&& (r&0xFF) != PT_LNTG))
|
&& (r&0xFF) != PT_LNTG))
|
||||||
|
@ -86,10 +86,10 @@ int update_STKM2(UPDATE_FUNC_ARGS) {
|
|||||||
|
|
||||||
//Go left
|
//Go left
|
||||||
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
||||||
if (((int)(player2[0])&0x01) == 0x01 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
if (((int)(player2[0])&0x01) == 0x01 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
||||||
{
|
{
|
||||||
if (r>=PT_NUM || ptypes[r&0xFF].state != ST_LIQUID
|
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
||||||
&& (r&0xFF) != PT_LNTG)
|
&& (r&0xFF) != PT_LNTG))
|
||||||
{
|
{
|
||||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||||
{
|
{
|
||||||
@ -125,7 +125,7 @@ int update_STKM2(UPDATE_FUNC_ARGS) {
|
|||||||
|
|
||||||
//Go right
|
//Go right
|
||||||
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
r = pmap[(int)(parts[i].y+10)][(int)(parts[i].x)];
|
||||||
if (((int)(player2[0])&0x02) == 0x02 && ((r&0xFF>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
if (((int)(player2[0])&0x02) == 0x02 && (((r&0xFF)>=PT_NUM) || ptypes[r&0xFF].state != ST_GAS))
|
||||||
{
|
{
|
||||||
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
if (r>=PT_NUM || (ptypes[r&0xFF].state != ST_LIQUID
|
||||||
&& (r&0xFF) != PT_LNTG))
|
&& (r&0xFF) != PT_LNTG))
|
||||||
|
@ -172,8 +172,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
{
|
{
|
||||||
fx = ((float)x)*((float)sw)/((float)rw);
|
fx = ((float)x)*((float)sw)/((float)rw);
|
||||||
fy = ((float)y)*((float)sh)/((float)rh);
|
fy = ((float)y)*((float)sh)/((float)rh);
|
||||||
fxc = modf(fx, &intp);
|
fxc = modff(fx, &intp);
|
||||||
fyc = modf(fy, &intp);
|
fyc = modff(fy, &intp);
|
||||||
fxceil = (int)ceil(fx);
|
fxceil = (int)ceil(fx);
|
||||||
fyceil = (int)ceil(fy);
|
fyceil = (int)ceil(fy);
|
||||||
if (fxceil>=sw) fxceil = sw-1;
|
if (fxceil>=sw) fxceil = sw-1;
|
||||||
@ -212,8 +212,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
{
|
{
|
||||||
fx = ((float)x)*((float)sw)/((float)rw);
|
fx = ((float)x)*((float)sw)/((float)rw);
|
||||||
fy = ((float)y)*((float)sh)/((float)rh);
|
fy = ((float)y)*((float)sh)/((float)rh);
|
||||||
fxc = modf(fx, &intp);
|
fxc = modff(fx, &intp);
|
||||||
fyc = modf(fy, &intp);
|
fyc = modff(fy, &intp);
|
||||||
fxceil = (int)ceil(fx);
|
fxceil = (int)ceil(fx);
|
||||||
fyceil = (int)ceil(fy);
|
fyceil = (int)ceil(fy);
|
||||||
if (fxceil>=sw) fxceil = sw-1;
|
if (fxceil>=sw) fxceil = sw-1;
|
||||||
|
@ -1628,31 +1628,11 @@ int save_name_ui(pixel *vid_buf)
|
|||||||
ui_edit_process(mx, my, b, &ed2);
|
ui_edit_process(mx, my, b, &ed2);
|
||||||
ui_checkbox_process(mx, my, b, bq, &cb);
|
ui_checkbox_process(mx, my, b, bq, &cb);
|
||||||
|
|
||||||
if (b && !bq && ((mx>=x0+9 && mx<x0+23 && my>=y0+22 && my<y0+36) ||
|
if ((b && !bq && ((mx>=x0+9 && mx<x0+23 && my>=y0+22 && my<y0+36) ||
|
||||||
(mx>=x0 && mx<x0+192 && my>=y0+74+YRES/4 && my<y0+90+YRES/4)))
|
(mx>=x0 && mx<x0+192 && my>=y0+74+YRES/4 && my<y0+90+YRES/4)))
|
||||||
|
|| sdl_key==SDLK_RETURN)
|
||||||
{
|
{
|
||||||
free(th);
|
if (th) free(th);
|
||||||
if (!ed.str[0])
|
|
||||||
return 0;
|
|
||||||
nd = strcmp(svf_name, ed.str) || !svf_own;
|
|
||||||
strncpy(svf_name, ed.str, 63);
|
|
||||||
svf_name[63] = 0;
|
|
||||||
strncpy(svf_description, ed2.str, 254);
|
|
||||||
svf_description[254] = 0;
|
|
||||||
if (nd)
|
|
||||||
{
|
|
||||||
strcpy(svf_id, "");
|
|
||||||
strcpy(svf_tags, "");
|
|
||||||
}
|
|
||||||
svf_open = 1;
|
|
||||||
svf_own = 1;
|
|
||||||
svf_publish = cb.checked;
|
|
||||||
return nd+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sdl_key==SDLK_RETURN)
|
|
||||||
{
|
|
||||||
free(th);
|
|
||||||
if (!ed.str[0])
|
if (!ed.str[0])
|
||||||
return 0;
|
return 0;
|
||||||
nd = strcmp(svf_name, ed.str) || !svf_own;
|
nd = strcmp(svf_name, ed.str) || !svf_own;
|
||||||
@ -1668,6 +1648,7 @@ int save_name_ui(pixel *vid_buf)
|
|||||||
svf_open = 1;
|
svf_open = 1;
|
||||||
svf_own = 1;
|
svf_own = 1;
|
||||||
svf_publish = cb.checked;
|
svf_publish = cb.checked;
|
||||||
|
free(old_vid);
|
||||||
return nd+1;
|
return nd+1;
|
||||||
}
|
}
|
||||||
if (sdl_key==SDLK_ESCAPE)
|
if (sdl_key==SDLK_ESCAPE)
|
||||||
@ -1677,7 +1658,8 @@ int save_name_ui(pixel *vid_buf)
|
|||||||
ed.focus = 0;
|
ed.focus = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(th);
|
if (th) free(th);
|
||||||
|
free(old_vid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3123,6 +3105,7 @@ finish:
|
|||||||
|
|
||||||
strcpy(search_expr, ed.str);
|
strcpy(search_expr, ed.str);
|
||||||
|
|
||||||
|
free(v_buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3196,8 +3179,8 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
|||||||
float ryf;
|
float ryf;
|
||||||
|
|
||||||
char *uri, *uri_2, *o_uri, *uri_3;
|
char *uri, *uri_2, *o_uri, *uri_3;
|
||||||
void *data, *info_data, *thumb_data_full;
|
void *data = NULL, *info_data, *thumb_data_full;
|
||||||
save_info *info = malloc(sizeof(save_info));
|
save_info *info = calloc(sizeof(save_info), 1);
|
||||||
void *http = NULL, *http_2 = NULL, *http_3 = NULL;
|
void *http = NULL, *http_2 = NULL, *http_3 = NULL;
|
||||||
int lasttime = TIMEOUT;
|
int lasttime = TIMEOUT;
|
||||||
int status, status_2, info_ready = 0, data_ready = 0, thumb_data_ready = 0;
|
int status, status_2, info_ready = 0, data_ready = 0, thumb_data_ready = 0;
|
||||||
@ -3605,9 +3588,10 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
|||||||
// Do Open!
|
// Do Open!
|
||||||
status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
//if(svf_last)
|
if(svf_last)
|
||||||
//free(svf_last);
|
free(svf_last);
|
||||||
svf_last = data;
|
svf_last = data;
|
||||||
|
data = NULL; //so we don't free it when returning
|
||||||
svf_lsize = data_size;
|
svf_lsize = data_size;
|
||||||
|
|
||||||
svf_open = 1;
|
svf_open = 1;
|
||||||
@ -3677,6 +3661,12 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
|||||||
http_async_req_close(http);
|
http_async_req_close(http);
|
||||||
if (http_2)
|
if (http_2)
|
||||||
http_async_req_close(http_2);
|
http_async_req_close(http_2);
|
||||||
|
if (http_3)
|
||||||
|
http_async_req_close(http_3);
|
||||||
|
info_parse("", info);
|
||||||
|
free(info);
|
||||||
|
free(old_vid);
|
||||||
|
if (data) free(data);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3685,6 +3675,17 @@ int info_parse(char *info_data, save_info *info)
|
|||||||
int i,j;
|
int i,j;
|
||||||
char *p,*q,*r,*s,*vu,*vd,*pu,*sd;
|
char *p,*q,*r,*s,*vu,*vd,*pu,*sd;
|
||||||
|
|
||||||
|
if (info->title) free(info->title);
|
||||||
|
if (info->name) free(info->name);
|
||||||
|
if (info->author) free(info->author);
|
||||||
|
if (info->date) free(info->date);
|
||||||
|
if (info->description) free(info->description);
|
||||||
|
if (info->tags) free(info->tags);
|
||||||
|
for (i=0;i<6;i++)
|
||||||
|
{
|
||||||
|
if (info->comments[i]) free(info->comments[i]);
|
||||||
|
if (info->commentauthors[i]) free(info->commentauthors[i]);
|
||||||
|
}
|
||||||
memset(info, 0, sizeof(save_info));
|
memset(info, 0, sizeof(save_info));
|
||||||
|
|
||||||
if (!info_data || !*info_data)
|
if (!info_data || !*info_data)
|
||||||
|
@ -1378,7 +1378,7 @@ int set_scale(int scale, int kiosk){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_grav_async()
|
void* update_grav_async(void* unused)
|
||||||
{
|
{
|
||||||
int done = 0;
|
int done = 0;
|
||||||
int thread_done = 0;
|
int thread_done = 0;
|
||||||
@ -2044,7 +2044,7 @@ int main(int argc, char *argv[])
|
|||||||
free(load_data);
|
free(load_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2))
|
if (sdl_key=='s' && ((sdl_mod & (KMOD_CTRL)) || !isplayer2))
|
||||||
{
|
{
|
||||||
if (it > 50)
|
if (it > 50)
|
||||||
it = 50;
|
it = 50;
|
||||||
@ -2178,7 +2178,7 @@ int main(int argc, char *argv[])
|
|||||||
bsy = 0;
|
bsy = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2))
|
if (sdl_key=='d' && ((sdl_mod & (KMOD_CTRL)) || !isplayer2))
|
||||||
DEBUG_MODE = !DEBUG_MODE;
|
DEBUG_MODE = !DEBUG_MODE;
|
||||||
if (sdl_key=='i')
|
if (sdl_key=='i')
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <math.h>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
Reference in New Issue
Block a user