Some 'const'-ing

This commit is contained in:
Arnout Engelen
2013-05-12 19:49:26 +00:00
parent 93378924f0
commit f6f9e890ea

View File

@@ -42,7 +42,7 @@ extern bool bughuntmode;
/* maps from inode to program-struct */ /* maps from inode to program-struct */
std::map <unsigned long, prg_node *> inodeproc; std::map <unsigned long, prg_node *> inodeproc;
bool is_number (char * string) { bool is_number (const char * string) {
while (*string) { while (*string) {
if (!isdigit (*string)) if (!isdigit (*string))
return false; return false;
@@ -51,7 +51,7 @@ bool is_number (char * string) {
return true; return true;
} }
unsigned long str2ulong (char * ptr) { unsigned long str2ulong (const char * ptr) {
unsigned long retval = 0; unsigned long retval = 0;
while ((*ptr >= '0') && (*ptr <= '9')) { while ((*ptr >= '0') && (*ptr <= '9')) {
@@ -61,7 +61,8 @@ unsigned long str2ulong (char * ptr) {
} }
return retval; return retval;
} }
int str2int (char * ptr) {
int str2int (const char * ptr) {
int retval = 0; int retval = 0;
while ((*ptr >= '0') && (*ptr <= '9')) { while ((*ptr >= '0') && (*ptr <= '9')) {
@@ -115,7 +116,7 @@ void setnode (unsigned long inode, pid_t pid)
} }
} }
void get_info_by_linkname (char * pid, char * linkname) { void get_info_by_linkname (const char * pid, const char * linkname) {
if (strncmp(linkname, "socket:[", 8) == 0) { if (strncmp(linkname, "socket:[", 8) == 0) {
setnode(str2ulong(linkname + 8), str2int(pid)); setnode(str2ulong(linkname + 8), str2int(pid));
} }
@@ -128,7 +129,7 @@ void get_info_by_linkname (char * pid, char * linkname) {
* for all inodes belonging to this PID * for all inodes belonging to this PID
* (/proc/pid/fd/42) * (/proc/pid/fd/42)
* */ * */
void get_info_for_pid(char * pid) { void get_info_for_pid(const char * pid) {
char dirname[10 + MAX_PID_LENGTH]; char dirname[10 + MAX_PID_LENGTH];
size_t dirlen = 10 + strlen(pid); size_t dirlen = 10 + strlen(pid);