Include some headers and move some functions

This commit is contained in:
Simon 2010-08-29 10:25:53 +01:00
parent a23f377731
commit c0563111f8
5 changed files with 45 additions and 34 deletions

View File

@ -1,10 +1,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h>
#include "http.h"
#include "md5.h"
#include "font.h" #include "font.h"
#include "defines.h" #include "defines.h"
#include "powder.h" #include "powder.h"
#include "interface.h" #include "interface.h"
#include "misc.h"
SDLMod sdl_mod; SDLMod sdl_mod;
int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0; int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;

34
main.c
View File

@ -1167,40 +1167,6 @@ int execute_tagop(pixel *vid_buf, char *op, char *tag)
return 0; return 0;
} }
struct strlist
{
char *str;
struct strlist *next;
};
void strlist_add(struct strlist **list, char *str)
{
struct strlist *item = malloc(sizeof(struct strlist));
item->str = mystrdup(str);
item->next = *list;
*list = item;
}
int strlist_find(struct strlist **list, char *str)
{
struct strlist *item;
for(item=*list; item; item=item->next)
if(!strcmp(item->str, str))
return 1;
return 0;
}
void strlist_free(struct strlist **list)
{
struct strlist *item;
while(*list)
{
item = *list;
*list = (*list)->next;
free(item);
}
}
void thumb_cache_inval(char *id); void thumb_cache_inval(char *id);
void execute_save(pixel *vid_buf) void execute_save(pixel *vid_buf)

28
misc.c
View File

@ -52,4 +52,32 @@ char *mystrdup(char *s)
return x; return x;
} }
return s; return s;
}
void strlist_add(struct strlist **list, char *str)
{
struct strlist *item = malloc(sizeof(struct strlist));
item->str = mystrdup(str);
item->next = *list;
*list = item;
}
int strlist_find(struct strlist **list, char *str)
{
struct strlist *item;
for(item=*list; item; item=item->next)
if(!strcmp(item->str, str))
return 1;
return 0;
}
void strlist_free(struct strlist **list)
{
struct strlist *item;
while(*list)
{
item = *list;
*list = (*list)->next;
free(item);
}
} }

12
misc.h
View File

@ -22,4 +22,16 @@ extern inline float restrict_flt(float f, float min, float max);
char *mystrdup(char *s); char *mystrdup(char *s);
struct strlist
{
char *str;
struct strlist *next;
};
void strlist_add(struct strlist **list, char *str);
int strlist_find(struct strlist **list, char *str);
void strlist_free(struct strlist **list);
#endif #endif

View File

@ -463,6 +463,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for(i=start; i<(NPART-starti); i+=inc) for(i=start; i<(NPART-starti); i+=inc)
if(parts[i].type) if(parts[i].type)
{ {
//printf("parts[%d].type: %d\n", i, parts[i].type);
lx = parts[i].x; lx = parts[i].x;
ly = parts[i].y; ly = parts[i].y;