diff options
author | bhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b> | 2010-07-30 17:57:11 +0000 |
---|---|---|
committer | bhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b> | 2010-07-30 17:57:11 +0000 |
commit | bc6949c9e6446cb5de4581dacc730676ff4c6d50 (patch) | |
tree | 1c41227d00ae22b729b9c0034c01b08d58144f03 | |
parent | 868cf1efc39b039f3d73201be5031bf693f9c8fd (diff) | |
download | cpulimit-bc6949c9e6446cb5de4581dacc730676ff4c6d50.tar.gz |
header dependencies fixed (thanks to Jonathan)
-rw-r--r-- | cpulimit.c | 5 | ||||
-rw-r--r-- | list.c | 7 | ||||
-rw-r--r-- | list.h | 4 | ||||
-rw-r--r-- | process.c | 10 | ||||
-rw-r--r-- | process.h | 7 | ||||
-rw-r--r-- | procutils.c | 19 | ||||
-rw-r--r-- | procutils.h | 8 |
7 files changed, 31 insertions, 29 deletions
@@ -101,7 +101,8 @@ int lazy = 0; static void *memrchr(const void *s, int c, size_t n) { - const unsigned char *start=s,*end=s; + const unsigned char *start = (const unsigned char*)s; + const unsigned char *end = (const unsigned char*)s; end+=n-1; @@ -474,7 +475,7 @@ int main(int argc, char **argv) { //executable file const char *cmd = argv[optind]; //command line arguments - char **cmd_args = malloc((argc-optind+1)*sizeof(char*)); + char **cmd_args = (char**)malloc((argc-optind+1)*sizeof(char*)); if (cmd_args==NULL) exit(2); for (i=0; i<argc-optind; i++) { cmd_args[i] = argv[i+optind]; @@ -24,6 +24,9 @@ * */ +#include <stdlib.h> +#include <string.h> + #include "list.h" #define EMPTYLIST NULL @@ -35,7 +38,7 @@ void init_list(struct list *l,int keysize) { } struct list_node *add_elem(struct list *l,void *elem) { - struct list_node *newnode=malloc(sizeof(struct list_node)); + struct list_node *newnode=(struct list_node*)malloc(sizeof(struct list_node)); newnode->data=elem; newnode->previous=l->last; newnode->next=NULL; @@ -105,7 +108,7 @@ struct list_node *xlocate_node(struct list *l,void *elem,int offset,int length) struct list_node *tmp; tmp=l->first; while(tmp!=NULL) { - if(!memcmp(tmp->data+offset,elem,length==0?l->keysize:length)) return (tmp); + if(!memcmp((char*)tmp->data+offset,elem,length==0?l->keysize:length)) return (tmp); tmp=tmp->next; } return EMPTYLIST; @@ -28,10 +28,6 @@ #define __LIST__ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifndef TRUE #define TRUE 1 #define FALSE 0 @@ -21,9 +21,15 @@ //TODO: add documentation to public functions -#include "process.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <signal.h> +#include <time.h> +#include <sys/utsname.h> -#include <fcntl.h> +#include "process.h" #ifdef __APPLE__ #include <sys/sysctl.h> @@ -23,15 +23,8 @@ #define __PROCESS_H -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <signal.h> -#include <time.h> #include <sys/time.h> #include <unistd.h> -#include <sys/utsname.h> #include <limits.h> //USER_HZ detection, from openssl code diff --git a/procutils.c b/procutils.c index 5c02584..edf6139 100644 --- a/procutils.c +++ b/procutils.c @@ -19,11 +19,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <signal.h> +#include <string.h> +#include <limits.h> #include <fcntl.h> #include <sys/utsname.h> +#include <sys/types.h> +#include <sys/stat.h> + #include "procutils.h" -#include "sys/types.h" -#include "sys/stat.h" #ifdef __APPLE__ #include <sys/sysctl.h> @@ -99,7 +106,7 @@ static int hash_process(struct process_family *f, struct process *p) if (*l == NULL) { //there is no process in this hashtable item //allocate the list - *l = malloc(sizeof(struct list)); + *l = (struct list*)malloc(sizeof(struct list)); init_list(*l, 4); add_elem(*l, p); ret = 0; @@ -185,7 +192,7 @@ int init_process_iterator(struct process_iterator *i) { i->c = 0; #endif - i->current = malloc(sizeof(struct process)); + i->current = (struct process*)malloc(sizeof(struct process)); memset(i->current, 0, sizeof(struct process)); return 0; } @@ -266,7 +273,7 @@ int create_process_family(struct process_family *f, pid_t father) ppid = getppid_of(ppid); } //allocate process descriptor - struct process *p = malloc(sizeof(struct process)); + struct process *p = (struct process*)malloc(sizeof(struct process)); //init process process_init(p, pid); if (ppid==1) { @@ -311,7 +318,7 @@ int update_process_family(struct process_family *f) exit(1); } //allocate and insert the process - struct process *p = malloc(sizeof(struct process)); + struct process *p = (struct process*)malloc(sizeof(struct process)); //init process process_init(p, pid); if (ancestor->member) { diff --git a/procutils.h b/procutils.h index d199710..b5a91a3 100644 --- a/procutils.h +++ b/procutils.h @@ -23,14 +23,8 @@ #define __PROCUTILS_H -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <signal.h> #include <sys/types.h> #include <dirent.h> -#include <string.h> -#include <limits.h> #include "list.h" #include "process.h" @@ -68,6 +62,8 @@ struct process_iterator { struct kinfo_proc *procList; int count; int c; +#elif defined __hpux + int count; #endif struct process *current; }; |