Просмотр исходного кода

convert strtok to strtok_r

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2663 fd59a12c-fef9-0310-b244-a6a79926bd2f
Angus Salkeld 16 лет назад
Родитель
Сommit
5dd31150ee
2 измененных файлов с 6 добавлено и 4 удалено
  1. 3 2
      exec/main.c
  2. 3 2
      lib/sa-confdb.c

+ 3 - 2
exec/main.c

@@ -1242,6 +1242,7 @@ int main (int argc, char **argv)
 	const char *config_iface_init;
 	char *config_iface;
 	char *iface;
+	char *strtok_save_pt;
 	int res, ch;
 	int background, setprio;
 	struct stat stat_out;
@@ -1349,7 +1350,7 @@ int main (int argc, char **argv)
 		corosync_exit_error (AIS_DONE_OBJDB);
 	}
 
-	iface = strtok(config_iface, ":");
+	iface = strtok_r(config_iface, ":", &strtok_save_pt);
 	while (iface)
 	{
 		res = lcr_ifact_reference (
@@ -1373,7 +1374,7 @@ int main (int argc, char **argv)
 		log_printf (LOGSYS_LEVEL_NOTICE, "%s", error_string);
 		config_modules[num_config_modules++] = config;
 
-		iface = strtok(NULL, ":");
+		iface = strtok_r(NULL, ":", &strtok_save_pt);
 	}
 	free(config_iface);
 

+ 3 - 2
lib/sa-confdb.c

@@ -97,6 +97,7 @@ static int load_config(void)
 	void *config_p;
 	struct config_iface_ver0 *config;
 	const char *error_string;
+	char *strtok_savept;
 
 	/* User's bootstrap config service */
 	config_iface = getenv("COROSYNC_DEFAULT_CONFIG_IFACE");
@@ -111,7 +112,7 @@ static int load_config(void)
 		return -1;
 	}
 
-	iface = strtok(config_iface, ":");
+	iface = strtok_r (config_iface, ":", &strtok_savept);
 	while (iface)
 	{
 		res = lcr_ifact_reference (
@@ -133,7 +134,7 @@ static int load_config(void)
 
 		config_modules[num_config_modules++] = config;
 
-		iface = strtok(NULL, ":");
+		iface = strtok_r (NULL, ":", &strtok_savept);
 	}
 	free(config_iface);