@cryptotaxi247 / netdata-1 / commits / ce615c7da

fixed initialization of all_files

Costa Tsaousis (ktsaou) committed Mar 28, 2015 at 06:03 UTC ce615c7daf064a01a6d33df630b2e633d0e29a5b
1 file changed +8 -7
src/plugins.d/apps_plugin.c
+8 -7
@@ -594,6 +594,7 @@ unsigned long file_descriptor_find_or_add(const char *name)
594 // check we have enough memory to add it
595 if(!all_files || all_files_len == all_files_size) {
596 void *old = all_files;
597 + int i;
598
599 // there is no empty slot
600 if(debug) fprintf(stderr, "apps.plugin: extending fd array to %d entries\n", all_files_size + FILE_DESCRIPTORS_INCREASE_STEP);
@@ -604,20 +605,20 @@ unsigned long file_descriptor_find_or_add(const char *name)
605 if(old && old != (void *)all_files) {
606 if(debug) fprintf(stderr, "apps.plugin: >> re-indexing.\n");
607 all_files_index.root = NULL;
607 - int i;
608 for(i = 0; i < all_files_size; i++) {
609 if(!all_files[i].count) continue;
610 file_descriptor_add(&all_files[i]);
611 }
612 - for(i = all_files_size; i < (all_files_size + FILE_DESCRIPTORS_INCREASE_STEP); i++) {
613 - all_files[i].count = 0;
614 - all_files[i].name = NULL;
615 - all_files[i].magic = 0x00000000;
616 - all_files[i].pos = i;
617 - }
612 if(debug) fprintf(stderr, "apps.plugin: >> re-indexing done.\n");
613 }
614
615 + for(i = all_files_size; i < (all_files_size + FILE_DESCRIPTORS_INCREASE_STEP); i++) {
616 + all_files[i].count = 0;
617 + all_files[i].name = NULL;
618 + all_files[i].magic = 0x00000000;
619 + all_files[i].pos = i;
620 + }
621 +
622 if(!all_files_size) all_files_len = 1;
623 all_files_size += FILE_DESCRIPTORS_INCREASE_STEP;
624 }