aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b>2010-07-30 17:57:11 +0000
committerbhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b>2010-07-30 17:57:11 +0000
commitbc6949c9e6446cb5de4581dacc730676ff4c6d50 (patch)
tree1c41227d00ae22b729b9c0034c01b08d58144f03
parent868cf1efc39b039f3d73201be5031bf693f9c8fd (diff)
downloadcpulimit-bc6949c9e6446cb5de4581dacc730676ff4c6d50.tar.gz
header dependencies fixed (thanks to Jonathan)
-rw-r--r--cpulimit.c5
-rw-r--r--list.c7
-rw-r--r--list.h4
-rw-r--r--process.c10
-rw-r--r--process.h7
-rw-r--r--procutils.c19
-rw-r--r--procutils.h8
7 files changed, 31 insertions, 29 deletions
diff --git a/cpulimit.c b/cpulimit.c
index 809d939..d1072bb 100644
--- a/cpulimit.c
+++ b/cpulimit.c
@@ -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];
diff --git a/list.c b/list.c
index 193eac9..49f84ce 100644
--- a/list.c
+++ b/list.c
@@ -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;
diff --git a/list.h b/list.h
index d505665..387f79c 100644
--- a/list.h
+++ b/list.h
@@ -28,10 +28,6 @@
#define __LIST__
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#ifndef TRUE
#define TRUE 1
#define FALSE 0
diff --git a/process.c b/process.c
index b2f8e6f..398d9e9 100644
--- a/process.c
+++ b/process.c
@@ -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>
diff --git a/process.h b/process.h
index db74969..0280ad6 100644
--- a/process.h
+++ b/process.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;
};
Un proyecto texto-plano.xyz