aboutsummaryrefslogtreecommitdiff
path: root/src/regex/gnunet-regex-profiler.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-06 11:14:11 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-06 11:14:11 +0000
commitf5beb3eaf163fc0bf2a4f86bd413d3ee6939cfea (patch)
treeb59a38ad9e2296b3d2c8cc3302f21cf6d3ecc458 /src/regex/gnunet-regex-profiler.c
parent6db64c5eae089e1d81cafbb051f65412790d16bc (diff)
downloadgnunet-f5beb3eaf163fc0bf2a4f86bd413d3ee6939cfea.tar.gz
gnunet-f5beb3eaf163fc0bf2a4f86bd413d3ee6939cfea.zip
-fix misc issues
Diffstat (limited to 'src/regex/gnunet-regex-profiler.c')
-rw-r--r--src/regex/gnunet-regex-profiler.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index 2114e2cb1..c5ecf3b4d 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -1231,41 +1231,55 @@ load_search_strings (const char *filename,
1231 "Could not find search strings file %s\n", filename); 1231 "Could not find search strings file %s\n", filename);
1232 return GNUNET_SYSERR; 1232 return GNUNET_SYSERR;
1233 } 1233 }
1234 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &filesize, GNUNET_YES, GNUNET_YES)) 1234 if (GNUNET_OK !=
1235 GNUNET_DISK_file_size (filename,
1236 &filesize,
1237 GNUNET_YES,
1238 GNUNET_YES))
1235 filesize = 0; 1239 filesize = 0;
1236 if (0 == filesize) 1240 if (0 == filesize)
1237 { 1241 {
1238 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Search strings file %s is empty.\n", filename); 1242 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1243 "Search strings file %s is empty.\n",
1244 filename);
1239 return GNUNET_SYSERR; 1245 return GNUNET_SYSERR;
1240 } 1246 }
1241 data = GNUNET_malloc (filesize); 1247 data = GNUNET_malloc (filesize + 1);
1242 if (filesize != GNUNET_DISK_fn_read (filename, data, filesize)) 1248 if (filesize != GNUNET_DISK_fn_read (filename,
1249 data,
1250 filesize))
1243 { 1251 {
1244 GNUNET_free (data); 1252 GNUNET_free (data);
1245 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not read search strings file %s.\n", 1253 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1254 "Could not read search strings file %s.\n",
1246 filename); 1255 filename);
1247 return GNUNET_SYSERR; 1256 return GNUNET_SYSERR;
1248 } 1257 }
1249 buf = data; 1258 buf = data;
1250 offset = 0; 1259 offset = 0;
1251 str_cnt = 0; 1260 str_cnt = 0;
1252 while (offset < (filesize - 1) && str_cnt < limit) 1261 while ( (offset < (filesize - 1)) && (str_cnt < limit) )
1253 { 1262 {
1254 offset++; 1263 offset++;
1255 if (((data[offset] == '\n')) && (buf != &data[offset])) 1264 if ( ((data[offset] == '\n')) &&
1265 (buf != &data[offset]) )
1256 { 1266 {
1257 data[offset] = '\0'; 1267 data[offset] = '\0';
1258 str_cnt++; 1268 str_cnt++;
1259 buf = &data[offset + 1]; 1269 buf = &data[offset + 1];
1260 } 1270 }
1261 else if ((data[offset] == '\n') || (data[offset] == '\0')) 1271 else if ( (data[offset] == '\n') ||
1272 (data[offset] == '\0') )
1262 buf = &data[offset + 1]; 1273 buf = &data[offset + 1];
1263 } 1274 }
1264 *strings = GNUNET_malloc (sizeof (char *) * str_cnt); 1275 *strings = GNUNET_malloc (sizeof (char *) * str_cnt);
1265 offset = 0; 1276 offset = 0;
1266 for (i = 0; i < str_cnt; i++) 1277 for (i = 0; i < str_cnt; i++)
1267 { 1278 {
1268 GNUNET_asprintf (&(*strings)[i], "%s%s", regex_prefix, &data[offset]); 1279 GNUNET_asprintf (&(*strings)[i],
1280 "%s%s",
1281 regex_prefix,
1282 &data[offset]);
1269 offset += strlen (&data[offset]) + 1; 1283 offset += strlen (&data[offset]) + 1;
1270 } 1284 }
1271 GNUNET_free (data); 1285 GNUNET_free (data);