comparison system/system_config.cc @ 50:35ce1a30f3f9

* Added va_end where there is a va_start * Used NULL instead of 0 (so it works on 64b)
author thib
date Fri, 17 Apr 2009 18:38:06 +0000
parents ed6c21dde840
children 15a18fbe6f21
comparison
equal deleted inserted replaced
49:6581f7eccd26 50:35ce1a30f3f9
132 AyuSysConfigStringItem(void) { 132 AyuSysConfigStringItem(void) {
133 original_data = 0; 133 original_data = 0;
134 old_data = 0; 134 old_data = 0;
135 new_data = 0; 135 new_data = 0;
136 } 136 }
137 ~AyuSysConfigStringItem(void) {
138 if (original_data) delete[] original_data;
139 if (old_data) delete[] old_data;
140 if (new_data) delete[] new_data;
141 }
137 AyuSysConfigStringItem(const AyuSysConfigStringItem& o) { 142 AyuSysConfigStringItem(const AyuSysConfigStringItem& o) {
138 original_data = 0; old_data = 0; new_data = 0; 143 original_data = 0; old_data = 0; new_data = 0;
139 if (o.original_data) { 144 if (o.original_data) {
140 original_data = new char[strlen(o.original_data)+1]; 145 original_data = new char[strlen(o.original_data)+1];
141 strcpy(original_data, o.original_data); 146 strcpy(original_data, o.original_data);
263 item_deal = 0; 268 item_deal = 0;
264 original_data = 0; 269 original_data = 0;
265 old_data = 0; 270 old_data = 0;
266 new_data = 0; 271 new_data = 0;
267 } 272 }
273 ~AyuSysConfigIntlistItem(void) {
274 if (original_data) delete[] original_data;
275 if (old_data) delete[] old_data;
276 if (new_data) delete[] new_data;
277 }
268 AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) { 278 AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) {
269 item_deal = o.item_deal; 279 item_deal = o.item_deal;
270 original_data = 0; old_data = 0; new_data = 0; 280 original_data = 0; old_data = 0; new_data = 0;
271 if (o.original_data) { 281 if (o.original_data) {
272 original_data = new int[item_deal]; 282 original_data = new int[item_deal];
543 if (vars == 0) { 553 if (vars == 0) {
544 // fprintf(stderr,"Cannot find config name '%s'\n",name); 554 // fprintf(stderr,"Cannot find config name '%s'\n",name);
545 va_start(va, deal); 555 va_start(va, deal);
546 for (i=0; i<deal; i++) { 556 for (i=0; i<deal; i++) {
547 int* var = va_arg(va, int*); 557 int* var = va_arg(va, int*);
548 if (var) *var = 0; 558 if (var != NULL) *var = 0;
549 } 559 }
560 va_end(va);
550 return -1; 561 return -1;
551 } else { 562 } else {
552 va_start(va, deal); 563 va_start(va, deal);
553 for (i=0; i<deal; i++) { 564 for (i=0; i<deal; i++) {
554 int* var = va_arg(va, int*); 565 int* var = va_arg(va, int*);
555 if (var) *var = vars[i]; 566 if (var != NULL) *var = vars[i];
556 } 567 }
568 va_end(va);
557 } 569 }
558 return 0; 570 return 0;
559 } 571 }
560 int AyuSysConfig::GetOriginalParam(const char* name, int deal, ...) const{ 572 int AyuSysConfig::GetOriginalParam(const char* name, int deal, ...) const{
561 HashStr str(name); 573 HashStr str(name);
564 if (vars == 0) { 576 if (vars == 0) {
565 // fprintf(stderr,"Cannot find config name '%s'\n",name); 577 // fprintf(stderr,"Cannot find config name '%s'\n",name);
566 va_start(va, deal); 578 va_start(va, deal);
567 for (i=0; i<deal; i++) { 579 for (i=0; i<deal; i++) {
568 int* var = va_arg(va, int*); 580 int* var = va_arg(va, int*);
569 if (var) *var = 0; 581 if (var != NULL) *var = 0;
570 } 582 }
583 va_end(va);
571 return -1; 584 return -1;
572 } else { 585 } else {
573 va_start(va, deal); 586 va_start(va, deal);
574 for (i=0; i<deal; i++) { 587 for (i=0; i<deal; i++) {
575 int* var = va_arg(va, int*); 588 int* var = va_arg(va, int*);
576 if (var) *var = vars[i]; 589 if (var != NULL) *var = vars[i];
577 } 590 }
591 va_end(va);
578 } 592 }
579 return 0; 593 return 0;
580 } 594 }
581 const int* AyuSysConfig::GetParamArray(const char* name, int& deal) const{ 595 const int* AyuSysConfig::GetParamArray(const char* name, int& deal) const{
582 HashStr str(name); 596 HashStr str(name);
592 str_config->orig.Set(str, 1, var); 606 str_config->orig.Set(str, 1, var);
593 } 607 }
594 void AyuSysConfig::SetParam(const char* name, int deal, ...) { 608 void AyuSysConfig::SetParam(const char* name, int deal, ...) {
595 if (deal >= MAXVARS) return ; 609 if (deal >= MAXVARS) return ;
596 HashStr str(name); 610 HashStr str(name);
597 int vars[MAXVARS]; va_list va; int i; 611 int vars[deal]; va_list va; int i;
598 va_start(va, deal); 612 va_start(va, deal);
599 for (i=0; i<deal; i++) vars[i] = va_arg(va, int); 613 for (i=0; i<deal; i++) vars[i] = va_arg(va, int);
614 va_end(va);
600 int_config->orig.Set(str, deal, vars); 615 int_config->orig.Set(str, deal, vars);
601 dirty_flag = 1; change_flag = 1; 616 dirty_flag = 1; change_flag = 1;
602 return; 617 return;
603 } 618 }
604 void AyuSysConfig::SetOrigParaStr(const char* name, const char* var) { 619 void AyuSysConfig::SetOrigParaStr(const char* name, const char* var) {
607 change_flag = 1; 622 change_flag = 1;
608 } 623 }
609 void AyuSysConfig::SetOrigParam(const char* name, int deal, ...) { 624 void AyuSysConfig::SetOrigParam(const char* name, int deal, ...) {
610 if (deal >= MAXVARS) return; 625 if (deal >= MAXVARS) return;
611 HashStr str(name); 626 HashStr str(name);
612 int vars[MAXVARS]; va_list va; int i; 627 int vars[deal]; va_list va; int i;
613 va_start(va, deal); 628 va_start(va, deal);
614 for(i=0; i<deal; i++) vars[i] = va_arg(va, int); 629 for(i=0; i<deal; i++) vars[i] = va_arg(va, int);
630 va_end(va);
615 int_config->orig.SetOrig(str, deal, vars); 631 int_config->orig.SetOrig(str, deal, vars);
616 change_flag = 1; 632 change_flag = 1;
617 } 633 }
618 void AyuSysConfig::SetOrigParamArray(const char* name, int deal, int* array) { 634 void AyuSysConfig::SetOrigParamArray(const char* name, int deal, int* array) {
619 HashStr str(name); 635 HashStr str(name);