ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.9 by root, Wed Aug 30 06:06:26 2006 UTC vs.
Revision 1.14 by root, Mon Sep 4 11:07:59 2006 UTC

1/* 1/*
2 * static char *rcsid_object_c = 2 * static char *rcsid_object_c =
3 * "$Id: object.C,v 1.9 2006/08/30 06:06:26 root Exp $"; 3 * "$Id: object.C,v 1.14 2006/09/04 11:07:59 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
37#endif /* win32 */ 37#endif /* win32 */
38#include <object.h> 38#include <object.h>
39#include <funcpoint.h> 39#include <funcpoint.h>
40#include <skills.h> 40#include <skills.h>
41#include <loader.h> 41#include <loader.h>
42#ifdef MEMORY_DEBUG
43int nroffreeobjects = 0;
44int nrofallocobjects = 0; 42int nrofallocobjects = 0;
45#undef OBJ_EXPAND
46#define OBJ_EXPAND 1
47#else
48object objarray[STARTMAX]; /* All objects, allocated this way at first */
49int nroffreeobjects = STARTMAX; /* How many OBs allocated and free (free) */
50int nrofallocobjects = STARTMAX; /* How many OBs allocated (free + used) */
51#endif
52 43
53object *objects; /* Pointer to the list of used objects */ 44object *objects; /* Pointer to the list of used objects */
54object *free_objects; /* Pointer to the list of unused objects */
55object *active_objects; /* List of active objects that need to be processed */ 45object *active_objects; /* List of active objects that need to be processed */
56 46
57short freearr_x[SIZEOFFREE]= 47short freearr_x[SIZEOFFREE]=
58 {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1, 48 {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,
59 0,1,2,3,3,3,3,3,3,3,2,1,0,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1}; 49 0,1,2,3,3,3,3,3,3,3,2,1,0,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1};
60short freearr_y[SIZEOFFREE]= 50short freearr_y[SIZEOFFREE]=
276 return op; 266 return op;
277} 267}
278 268
279/* 269/*
280 * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. 270 * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump.
281 * Some error messages. 271 * Some error messages.
282 * The result of the dump is stored in the static global errmsg array. 272 * The result of the dump is stored in the static global errmsg array.
283 */ 273 */
284 274
285void dump_object2(object *op) { 275void dump_object2(object *op) {
276errmsg[0] = 0;
277return;
278 //TODO//D#d#
279#if 0
286 char *cp; 280 char *cp;
287/* object *tmp;*/ 281/* object *tmp;*/
288 282
289 if(op->arch!=NULL) { 283 if(op->arch!=NULL) {
290 strcat(errmsg,"arch "); 284 strcat(errmsg,"arch ");
315 for (tmp=op->inv; tmp; tmp=tmp->below) 309 for (tmp=op->inv; tmp; tmp=tmp->below)
316 dump_object2(tmp); 310 dump_object2(tmp);
317#endif 311#endif
318 strcat(errmsg,"end\n"); 312 strcat(errmsg,"end\n");
319 } 313 }
314#endif
320} 315}
321 316
322/* 317/*
323 * Dumps an object. Returns output in the static global errmsg array. 318 * Dumps an object. Returns output in the static global errmsg array.
324 */ 319 */
329 return; 324 return;
330 } 325 }
331 errmsg[0]='\0'; 326 errmsg[0]='\0';
332 dump_object2(op); 327 dump_object2(op);
333} 328}
334
335/* GROS - Dumps an object. Return the result into a string */
336/* Note that no checking is done for the validity of the target string, so */
337/* you need to be sure that you allocated enough space for it. */
338void dump_me(object *op, char *outstr)
339{
340 char *cp;
341
342 if(op==NULL)
343 {
344 strcpy(outstr,"[NULL pointer]");
345 return;
346 }
347 outstr[0]='\0';
348
349 if(op->arch!=NULL)
350 {
351 strcat(outstr,"arch ");
352 strcat(outstr,op->arch->name?op->arch->name:"(null)");
353 strcat(outstr,"\n");
354 if((cp=get_ob_diff(op,&empty_archetype->clone))!=NULL)
355 strcat(outstr,cp);
356 strcat(outstr,"end\n");
357 }
358 else
359 {
360 strcat(outstr,"Object ");
361 if (op->name==NULL)
362 strcat(outstr, "(null)");
363 else
364 strcat(outstr,op->name);
365 strcat(outstr,"\n");
366 strcat(outstr,"end\n");
367 }
368}
369
370/*
371 * This is really verbose...Can be triggered by the P key while in DM mode.
372 * All objects are dumped to stderr (or alternate logfile, if in server-mode)
373 */
374 329
375void dump_all_objects(void) { 330void dump_all_objects(void) {
376 object *op; 331 object *op;
377 for(op=objects;op!=NULL;op=op->next) { 332 for(op=objects;op!=NULL;op=op->next) {
378 dump_object(op); 333 dump_object(op);
414 * Used only by the patch command, but not all that useful. 369 * Used only by the patch command, but not all that useful.
415 * Enables features like "patch <name-of-other-player> food 999" 370 * Enables features like "patch <name-of-other-player> food 999"
416 */ 371 */
417 372
418object *find_object_name(const char *str) { 373object *find_object_name(const char *str) {
419 const char *name=add_string(str); 374 const char *name = shstr::find (str);
420 object *op; 375 object *op;
421 for(op=objects;op!=NULL;op=op->next) 376 for(op=objects;op!=NULL;op=op->next)
422 if(op->name==name) 377 if(&op->name == name)
423 break; 378 break;
424 free_string(name); 379
425 return op; 380 return op;
426} 381}
427 382
428void free_all_object_data(void) { 383void free_all_object_data ()
429#ifdef MEMORY_DEBUG 384{
430 object *op, *next; 385 LOG (llevDebug, "%d allocated objects\n", nrofallocobjects);
431
432 for (op=free_objects; op!=NULL; ) {
433 next=op->next;
434 free(op);
435 nrofallocobjects--;
436 nroffreeobjects--;
437 op=next;
438 }
439#endif
440 LOG(llevDebug,"%d allocated objects, %d free objects, STARMAX=%d\n",
441 nrofallocobjects, nroffreeobjects,STARTMAX);
442} 386}
443 387
444/* 388/*
445 * Returns the object which this object marks as being the owner. 389 * Returns the object which this object marks as being the owner.
446 * A id-scheme is used to avoid pointing to objects which have been 390 * A id-scheme is used to avoid pointing to objects which have been
473 op->owner->refcount--; 417 op->owner->refcount--;
474 418
475 op->owner = NULL; 419 op->owner = NULL;
476 op->ownercount = 0; 420 op->ownercount = 0;
477} 421}
478
479
480 422
481/* 423/*
482 * Sets the owner and sets the skill and exp pointers to owner's current 424 * Sets the owner and sets the skill and exp pointers to owner's current
483 * skill and experience objects. 425 * skill and experience objects.
484 */ 426 */
531 } 473 }
532 set_owner(op, owner); 474 set_owner(op, owner);
533 475
534} 476}
535 477
536/*
537 * Resets vital variables in an object
538 */
539
540void reset_object(object *op) {
541
542 op->name = NULL;
543 op->name_pl = NULL;
544 op->title = NULL;
545 op->race = NULL;
546 op->slaying = NULL;
547 op->skill = NULL;
548 op->msg = NULL;
549 op->materialname = NULL;
550 op->lore = NULL;
551 clear_object(op);
552}
553
554/* Zero the key_values on op, decrementing the shared-string 478/* Zero the key_values on op, decrementing the shared-string
555 * refcounts and freeing the links. 479 * refcounts and freeing the links.
556 */ 480 */
557static void free_key_values(object * op) { 481static void free_key_values(object * op)
558 key_value * i; 482{
559 key_value * next = NULL; 483 for (key_value *i = op->key_values; i != 0; )
560 484 {
561 if (op->key_values == NULL) return; 485 key_value *next = i->next;
486 delete i;
487 i = next;
562 488 }
563 for (i = op->key_values; i != NULL; i = next) { 489
564 /* Store next *first*. */
565 next = i->next;
566
567 if (i->key) FREE_AND_CLEAR_STR(i->key);
568 if (i->value) FREE_AND_CLEAR_STR(i->value);
569 i->next = NULL;
570 free(i);
571 }
572
573 op->key_values = NULL; 490 op->key_values = 0;
574} 491}
575 492
493void object::clear ()
494{
495 attachable_base::clear ();
496
497 free_key_values (this);
498
499 name = 0;
500 name_pl = 0;
501 title = 0;
502 race = 0;
503 slaying = 0;
504 skill = 0;
505 msg = 0;
506 lore = 0;
507 custom_name = 0;
508 materialname = 0;
509
510 memset (static_cast<object_pod *>(this), 0, sizeof (object_pod));
511
512 SET_FLAG (this, FLAG_REMOVED);
513}
514
515void object::clone (object *destination)
516{
517 *(object_copy *)destination = *(object_copy *)this;
518 *(object_pod *)destination = *(object_pod *)this;
519
520 if (self || cb)
521 INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination));
522}
576 523
577/* 524/*
578 * clear_object() frees everything allocated by an object, and also 525 * clear_object() frees everything allocated by an object, and also
579 * clears all variables and flags to default settings. 526 * clears all variables and flags to default settings.
580 */ 527 */
581 528
582void clear_object(object *op) { 529void clear_object (object *op)
530{
583 op->clear (); 531 op->clear ();
584 532
585 event *evt;
586 event *evt2;
587
588 /* redo this to be simpler/more efficient. Was also seeing
589 * crashes in the old code. Move this to the top - am
590 * seeing periodic crashes in this code, and would like to have
591 * as much info available as possible (eg, object name).
592 */
593 for (evt = op->events; evt; evt=evt2) {
594 evt2 = evt->next;
595
596 if (evt->hook != NULL) FREE_AND_CLEAR_STR(evt->hook);
597 if (evt->plugin != NULL) FREE_AND_CLEAR_STR(evt->plugin);
598 if (evt->options != NULL) FREE_AND_CLEAR_STR(evt->options);
599
600 free(evt);
601 }
602 op->events = NULL;
603
604 free_key_values(op);
605
606 /* the memset will clear all these values for us, but we need
607 * to reduce the refcount on them.
608 */
609 if (op->name!=NULL) FREE_AND_CLEAR_STR(op->name);
610 if (op->name_pl!=NULL) FREE_AND_CLEAR_STR(op->name_pl);
611 if (op->title != NULL) FREE_AND_CLEAR_STR(op->title);
612 if (op->race!=NULL) FREE_AND_CLEAR_STR(op->race);
613 if (op->slaying!=NULL) FREE_AND_CLEAR_STR(op->slaying);
614 if (op->skill!=NULL) FREE_AND_CLEAR_STR(op->skill);
615 if (op->msg!=NULL) FREE_AND_CLEAR_STR(op->msg);
616 if (op->lore!=NULL) FREE_AND_CLEAR_STR(op->lore);
617 if (op->materialname!= NULL) FREE_AND_CLEAR_STR(op->materialname);
618
619
620 memset((void*)op, 0, sizeof (object_special));
621 /* Below here, we clear things that are not done by the memset,
622 * or set default values that are not zero.
623 */
624 /* This is more or less true */
625 SET_FLAG(op, FLAG_REMOVED);
626
627
628 op->contr = NULL; 533 op->contr = NULL;
629 op->below=NULL; 534 op->below = NULL;
630 op->above=NULL; 535 op->above = NULL;
631 op->inv=NULL; 536 op->inv = NULL;
632 op->events=NULL;
633 op->container=NULL; 537 op->container=NULL;
634 op->env=NULL; 538 op->env=NULL;
635 op->more=NULL; 539 op->more=NULL;
636 op->head=NULL; 540 op->head=NULL;
637 op->map=NULL; 541 op->map=NULL;
638 op->refcount=0; 542 op->refcount=0;
639 op->active_next = NULL; 543 op->active_next = NULL;
640 op->active_prev = NULL; 544 op->active_prev = NULL;
641 /* What is not cleared is next, prev, and count */ 545 /* What is not cleared is next, prev, and count */
642 546
643 op->expmul=1.0; 547 op->expmul = 1.0;
644 op->face = blank_face; 548 op->face = blank_face;
645 op->attacked_by_count = (tag_t) -1; 549 op->attacked_by_count = -1;
550
646 if (settings.casting_time) 551 if (settings.casting_time)
647 op->casting_time = -1; 552 op->casting_time = -1;
648
649} 553}
650 554
651/* 555/*
652 * copy object first frees everything allocated by the second object, 556 * copy object first frees everything allocated by the second object,
653 * and then copies the contends of the first object into the second 557 * and then copies the contends of the first object into the second
655 * data that is malloc'd needs to be re-malloc/copied. Otherwise, 559 * data that is malloc'd needs to be re-malloc/copied. Otherwise,
656 * if the first object is freed, the pointers in the new object 560 * if the first object is freed, the pointers in the new object
657 * will point at garbage. 561 * will point at garbage.
658 */ 562 */
659 563
660void copy_object(object *op2, object *op) { 564void copy_object (object *op2, object *op)
661 int is_freed=QUERY_FLAG(op,FLAG_FREED),is_removed=QUERY_FLAG(op,FLAG_REMOVED); 565{
662 event *evt, *evt2, *evt_new; 566 bool is_freed = QUERY_FLAG (op, FLAG_FREED);
567 bool is_removed = QUERY_FLAG (op, FLAG_REMOVED);
663 568
664 op->clear ();
665
666 /* Decrement the refcounts, but don't bother zeroing the fields;
667 they'll be overwritten by memcpy. */
668 if(op->name!=NULL) free_string(op->name);
669 if(op->name_pl!=NULL) free_string(op->name_pl);
670 if(op->title!=NULL) free_string(op->title);
671 if(op->race!=NULL) free_string(op->race);
672 if(op->slaying!=NULL) free_string(op->slaying);
673 if(op->skill!=NULL) free_string(op->skill);
674 if(op->msg!=NULL) free_string(op->msg);
675 if(op->lore!=NULL) free_string(op->lore);
676 if(op->materialname != NULL) free_string(op->materialname);
677 if(op->custom_name != NULL) free_string(op->custom_name);
678
679 /* Basically, same code as from clear_object() */
680 for (evt = op->events; evt; evt=evt2) {
681 evt2 = evt->next;
682
683 if (evt->hook != NULL) FREE_AND_CLEAR_STR(evt->hook);
684 if (evt->plugin != NULL) FREE_AND_CLEAR_STR(evt->plugin);
685 if (evt->options != NULL) FREE_AND_CLEAR_STR(evt->options);
686
687 free(evt);
688 }
689 op->events = NULL;
690
691 free_key_values(op);
692
693 *(object_special *)op = *(object_special *)op2;
694 op2->clone (op); 569 op2->clone (op);
695 570
696 if(is_freed) SET_FLAG(op,FLAG_FREED); 571 if (is_freed) SET_FLAG (op, FLAG_FREED);
697 if(is_removed) SET_FLAG(op,FLAG_REMOVED); 572 if (is_removed) SET_FLAG (op, FLAG_REMOVED);
698 if(op->name!=NULL) add_refcount(op->name);
699 if(op->name_pl!=NULL) add_refcount(op->name_pl);
700 if(op->title!=NULL) add_refcount(op->title);
701 if(op->race!=NULL) add_refcount(op->race);
702 if(op->slaying!=NULL) add_refcount(op->slaying);
703 if(op->skill!=NULL) add_refcount(op->skill);
704 if(op->lore!=NULL) add_refcount(op->lore);
705 if(op->msg!=NULL) add_refcount(op->msg);
706 if(op->custom_name!=NULL) add_refcount(op->custom_name);
707 if (op->materialname != NULL) add_refcount(op->materialname);
708 573
709 if((op2->speed<0) && !editor) 574 if (op2->speed < 0)
710 op->speed_left=op2->speed_left-RANDOM()%200/100.0; 575 op->speed_left = op2->speed_left - RANDOM() % 200 / 100.0;
711 576
712 /* Copy over event information */
713 evt2 = NULL;
714 for (evt = op2->events; evt; evt=evt->next) {
715 evt_new = (event *) malloc(sizeof(event));
716 memcpy(evt_new, evt, sizeof(event));
717 if (evt_new->hook) add_refcount(evt_new->hook);
718 if (evt_new->plugin) add_refcount(evt_new->plugin);
719 if (evt_new->options) add_refcount(evt_new->options);
720 evt_new->next = NULL;
721
722 /* Try to be a little clever here, and store away the
723 * last event we copied, so that its simpler to update the
724 * pointer.
725 */
726 if (evt2)
727 evt2->next = evt_new;
728 else
729 op->events = evt_new;
730
731 evt2 = evt_new;
732 }
733 /* Copy over key_values, if any. */ 577 /* Copy over key_values, if any. */
734 if (op2->key_values != NULL) { 578 if (op2->key_values != NULL)
579 {
735 key_value * tail = NULL; 580 key_value *tail = NULL;
736 key_value * i; 581 key_value *i;
737 582
738 op->key_values = NULL; 583 op->key_values = NULL;
739 584
740 for (i = op2->key_values; i != NULL; i = i->next) { 585 for (i = op2->key_values; i != NULL; i = i->next)
741 key_value * new_link = (key_value *) malloc(sizeof(key_value)); 586 {
587 key_value *new_link = new key_value;
742 588
743 new_link->next = NULL; 589 new_link->next = NULL;
744 new_link->key = add_refcount(i->key); 590 new_link->key = i->key;
745 if (i->value)
746 new_link->value = add_refcount(i->value); 591 new_link->value = i->value;
747 else
748 new_link->value = NULL;
749 592
750 /* Try and be clever here, too. */ 593 /* Try and be clever here, too. */
751 if (op->key_values == NULL) { 594 if (op->key_values == NULL)
595 {
752 op->key_values = new_link; 596 op->key_values = new_link;
753 tail = new_link; 597 tail = new_link;
598 }
754 } else { 599 else
600 {
755 tail->next = new_link; 601 tail->next = new_link;
756 tail = new_link; 602 tail = new_link;
757 } 603 }
758 } 604 }
759 } 605 }
760 606
761 update_ob_speed(op); 607 update_ob_speed (op);
762}
763
764/*
765 * expand_objects() allocates more objects for the list of unused objects.
766 * It is called from get_object() if the unused list is empty.
767 */
768
769void expand_objects(void) {
770 int i;
771 object *obj;
772 obj = (object *) CALLOC(OBJ_EXPAND,sizeof(object));
773
774 if(obj==NULL)
775 fatal(OUT_OF_MEMORY);
776 free_objects=obj;
777 obj[0].prev=NULL;
778 obj[0].next= &obj[1],
779 SET_FLAG(&(obj[0]), FLAG_REMOVED);
780 SET_FLAG(&(obj[0]), FLAG_FREED);
781
782 for(i=1;i<OBJ_EXPAND-1;i++) {
783 obj[i].next= &obj[i+1],
784 obj[i].prev= &obj[i-1],
785 SET_FLAG(&(obj[i]), FLAG_REMOVED);
786 SET_FLAG(&(obj[i]), FLAG_FREED);
787 }
788 obj[OBJ_EXPAND-1].prev= &obj[OBJ_EXPAND-2],
789 obj[OBJ_EXPAND-1].next=NULL,
790 SET_FLAG(&(obj[OBJ_EXPAND-1]), FLAG_REMOVED);
791 SET_FLAG(&(obj[OBJ_EXPAND-1]), FLAG_FREED);
792
793 nrofallocobjects += OBJ_EXPAND;
794 nroffreeobjects += OBJ_EXPAND;
795} 608}
796 609
797/* 610/*
798 * get_object() grabs an object from the list of unused objects, makes 611 * get_object() grabs an object from the list of unused objects, makes
799 * sure it is initialised, and returns it. 612 * sure it is initialised, and returns it.
800 * If there are no free objects, expand_objects() is called to get more. 613 * If there are no free objects, expand_objects() is called to get more.
801 */ 614 */
802 615
803object *get_object(void) { 616object *get_object ()
617{
618 object *op = new object;
619
620 op->count = ++ob_count;
621
622 op->active_next = 0;
623 op->active_prev = 0;
624
625 op->next = objects;
626 op->prev = 0;
627
628 if (objects)
629 objects->prev = op;
630
804 object *op; 631 objects = op;
805 632
806 if(free_objects==NULL) {
807 expand_objects();
808 }
809 op=free_objects;
810#ifdef MEMORY_DEBUG
811 /* The idea is hopefully by doing a realloc, the memory
812 * debugging program will now use the current stack trace to
813 * report leaks.
814 */
815 op = realloc(op, sizeof(object));
816 SET_FLAG(op, FLAG_REMOVED); 633 SET_FLAG (op, FLAG_REMOVED);
817 SET_FLAG(op, FLAG_FREED);
818#endif
819 634
820 if(!QUERY_FLAG(op,FLAG_FREED)) {
821 LOG(llevError,"Fatal: Getting busy object.\n");
822 }
823 free_objects=op->next;
824 if(free_objects!=NULL)
825 free_objects->prev=NULL;
826 op->count= ++ob_count;
827 op->name=NULL;
828 op->name_pl=NULL;
829 op->title=NULL;
830 op->race=NULL;
831 op->slaying=NULL;
832 op->skill = NULL;
833 op->lore=NULL;
834 op->msg=NULL;
835 op->materialname=NULL;
836 op->next=objects;
837 op->prev=NULL;
838 op->active_next = NULL;
839 op->active_prev = NULL;
840 if(objects!=NULL)
841 objects->prev=op;
842 objects=op;
843 clear_object(op);
844 SET_FLAG(op,FLAG_REMOVED);
845 nroffreeobjects--;
846 return op; 635 return op;
847} 636}
848 637
849/* 638/*
850 * If an object with the IS_TURNABLE() flag needs to be turned due 639 * If an object with the IS_TURNABLE() flag needs to be turned due
871 /* No reason putting the archetypes objects on the speed list, 660 /* No reason putting the archetypes objects on the speed list,
872 * since they never really need to be updated. 661 * since they never really need to be updated.
873 */ 662 */
874 663
875 if (QUERY_FLAG(op, FLAG_FREED) && op->speed) { 664 if (QUERY_FLAG(op, FLAG_FREED) && op->speed) {
876 LOG(llevError,"Object %s is freed but has speed.\n", op->name); 665 LOG(llevError,"Object %s is freed but has speed.\n", &op->name);
877#ifdef MANY_CORES 666#ifdef MANY_CORES
878 abort(); 667 abort();
879#else 668#else
880 op->speed = 0; 669 op->speed = 0;
881#endif 670#endif
965 * UP_OBJ_FACE: only the objects face has changed. 754 * UP_OBJ_FACE: only the objects face has changed.
966 */ 755 */
967 756
968void update_object(object *op, int action) { 757void update_object(object *op, int action) {
969 int update_now=0, flags; 758 int update_now=0, flags;
970 MoveType move_on, move_off, move_block, move_slow; 759 MoveType move_on, move_off, move_block, move_slow;
971 760
972 if (op == NULL) { 761 if (op == NULL) {
973 /* this should never happen */ 762 /* this should never happen */
974 LOG(llevDebug,"update_object() called for NULL object.\n"); 763 LOG(llevDebug,"update_object() called for NULL object.\n");
975 return; 764 return;
1058 * 847 *
1059 * If free_inventory is set, free inventory as well. Else drop items in 848 * If free_inventory is set, free inventory as well. Else drop items in
1060 * inventory to the ground. 849 * inventory to the ground.
1061 */ 850 */
1062 851
852void
1063void free_object(object *ob) { 853free_object (object * ob)
854{
1064 free_object2(ob, 0); 855 free_object2 (ob, 0);
1065} 856}
857
858void
1066void free_object2(object *ob, int free_inventory) { 859free_object2 (object * ob, int free_inventory)
860{
1067 object *tmp,*op; 861 object *tmp, *op;
1068 862
1069 ob->clear ();
1070
1071 if (!QUERY_FLAG(ob,FLAG_REMOVED)) { 863 if (!QUERY_FLAG (ob, FLAG_REMOVED))
864 {
1072 LOG(llevDebug,"Free object called with non removed object\n"); 865 LOG (llevDebug, "Free object called with non removed object\n");
1073 dump_object(ob); 866 dump_object (ob);
1074#ifdef MANY_CORES 867#ifdef MANY_CORES
1075 abort(); 868 abort ();
1076#endif 869#endif
1077 } 870 }
871
1078 if(QUERY_FLAG(ob,FLAG_FRIENDLY)) { 872 if (QUERY_FLAG (ob, FLAG_FRIENDLY))
873 {
1079 LOG(llevMonster,"Warning: tried to free friendly object.\n"); 874 LOG (llevMonster, "Warning: tried to free friendly object.\n");
1080 remove_friendly_object(ob); 875 remove_friendly_object (ob);
1081 } 876 }
877
1082 if(QUERY_FLAG(ob,FLAG_FREED)) { 878 if (QUERY_FLAG (ob, FLAG_FREED))
879 {
1083 dump_object(ob); 880 dump_object (ob);
1084 LOG(llevError,"Trying to free freed object.\n%s\n",errmsg); 881 LOG (llevError, "Trying to free freed object.\n%s\n", errmsg);
1085 return; 882 return;
1086 } 883 }
884
1087 if(ob->more!=NULL) { 885 if (ob->more != NULL)
886 {
1088 free_object2(ob->more, free_inventory); 887 free_object2 (ob->more, free_inventory);
1089 ob->more=NULL; 888 ob->more = NULL;
1090 } 889 }
890
1091 if (ob->inv) { 891 if (ob->inv)
892 {
1092 /* Only if the space blocks everything do we not process - 893 /* Only if the space blocks everything do we not process -
1093 * if some form of movemnt is allowed, let objects 894 * if some form of movemnt is allowed, let objects
1094 * drop on that space. 895 * drop on that space.
1095 */ 896 */
1096 if (free_inventory || ob->map==NULL || ob->map->in_memory!=MAP_IN_MEMORY || 897 if (free_inventory || ob->map == NULL
898 || ob->map->in_memory != MAP_IN_MEMORY
1097 (GET_MAP_MOVE_BLOCK(ob->map, ob->x, ob->y) == MOVE_ALL)) 899 || (GET_MAP_MOVE_BLOCK (ob->map, ob->x, ob->y) == MOVE_ALL))
1098 { 900 {
1099 op=ob->inv; 901 op = ob->inv;
1100 while(op!=NULL) { 902
903 while (op != NULL)
904 {
1101 tmp=op->below; 905 tmp = op->below;
1102 remove_ob(op); 906 remove_ob (op);
1103 free_object2(op, free_inventory); 907 free_object2 (op, free_inventory);
1104 op=tmp; 908 op = tmp;
1105 }
1106 }
1107 else { /* Put objects in inventory onto this space */
1108 op=ob->inv;
1109 while(op!=NULL) {
1110 tmp=op->below;
1111 remove_ob(op);
1112 if(QUERY_FLAG(op,FLAG_STARTEQUIP)||QUERY_FLAG(op,FLAG_NO_DROP) ||
1113 op->type==RUNE || op->type==TRAP || QUERY_FLAG(op,FLAG_IS_A_TEMPLATE))
1114 free_object(op);
1115 else {
1116 op->x=ob->x;
1117 op->y=ob->y;
1118 insert_ob_in_map(op,ob->map,NULL,0); /* Insert in same map as the envir */
1119 }
1120 op=tmp;
1121 }
1122 }
1123 } 909 }
910 }
911 else
912 { /* Put objects in inventory onto this space */
913 op = ob->inv;
914
915 while (op != NULL)
916 {
917 tmp = op->below;
918 remove_ob (op);
919
920 if (QUERY_FLAG (op, FLAG_STARTEQUIP)
921 || QUERY_FLAG (op, FLAG_NO_DROP) || op->type == RUNE
922 || op->type == TRAP || QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
923 free_object (op);
924 else
925 {
926 op->x = ob->x;
927 op->y = ob->y;
928 insert_ob_in_map (op, ob->map, NULL, 0); /* Insert in same map as the envir */
929 }
930
931 op = tmp;
932 }
933 }
934 }
935
1124 /* Remove object from the active list */ 936 /* Remove object from the active list */
1125 ob->speed = 0; 937 ob->speed = 0;
1126 update_ob_speed(ob); 938 update_ob_speed (ob);
1127 939
1128 SET_FLAG(ob, FLAG_FREED); 940 SET_FLAG (ob, FLAG_FREED);
1129 ob->count = 0; 941 ob->count = 0;
1130 942
1131 /* Remove this object from the list of used objects */ 943 /* Remove this object from the list of used objects */
1132 if(ob->prev==NULL) { 944 if (ob->prev == NULL)
945 {
1133 objects=ob->next; 946 objects = ob->next;
947
1134 if(objects!=NULL) 948 if (objects != NULL)
1135 objects->prev=NULL; 949 objects->prev = NULL;
950 }
951 else
1136 } 952 {
1137 else {
1138 ob->prev->next=ob->next; 953 ob->prev->next = ob->next;
954
1139 if(ob->next!=NULL) 955 if (ob->next != NULL)
1140 ob->next->prev=ob->prev; 956 ob->next->prev = ob->prev;
1141 }
1142
1143 if(ob->name!=NULL) FREE_AND_CLEAR_STR(ob->name);
1144 if(ob->name_pl!=NULL) FREE_AND_CLEAR_STR(ob->name_pl);
1145 if(ob->title!=NULL) FREE_AND_CLEAR_STR(ob->title);
1146 if(ob->race!=NULL) FREE_AND_CLEAR_STR(ob->race);
1147 if(ob->slaying!=NULL) FREE_AND_CLEAR_STR(ob->slaying);
1148 if(ob->skill!=NULL) FREE_AND_CLEAR_STR(ob->skill);
1149 if(ob->lore!=NULL) FREE_AND_CLEAR_STR(ob->lore);
1150 if(ob->msg!=NULL) FREE_AND_CLEAR_STR(ob->msg);
1151 if(ob->materialname!=NULL) FREE_AND_CLEAR_STR(ob->materialname);
1152
1153 957 }
1154 /* Why aren't events freed? */ 958
1155 free_key_values(ob); 959 free_key_values (ob);
1156 960
1157#if 0 /* MEMORY_DEBUG*/
1158 /* This is a nice idea. Unfortunately, a lot of the code in crossfire
1159 * presumes the freed_object will stick around for at least a little
1160 * bit
1161 */
1162 /* this is necessary so that memory debugging programs will
1163 * be able to accurately report source of malloc. If we recycle
1164 * objects, then some other area may be doing the get_object
1165 * and not freeing it, but the original one that malloc'd the
1166 * object will get the blame.
1167 */
1168 free(ob);
1169#else
1170
1171 /* Now link it with the free_objects list: */ 961 /* Now link it with the free_objects list: */
1172 ob->prev=NULL; 962 ob->prev = 0;
1173 ob->next=free_objects; 963 ob->next = 0;
1174 if(free_objects!=NULL)
1175 free_objects->prev=ob;
1176 free_objects=ob;
1177 nroffreeobjects++;
1178#endif
1179}
1180 964
1181/* 965 delete ob;
1182 * count_free() returns the number of objects on the list of free objects.
1183 */
1184
1185int count_free(void) {
1186 int i=0;
1187 object *tmp=free_objects;
1188 while(tmp!=NULL)
1189 tmp=tmp->next, i++;
1190 return i;
1191}
1192
1193/*
1194 * count_used() returns the number of objects on the list of used objects.
1195 */
1196
1197int count_used(void) {
1198 int i=0;
1199 object *tmp=objects;
1200 while(tmp!=NULL)
1201 tmp=tmp->next, i++;
1202 return i;
1203}
1204
1205/*
1206 * count_active() returns the number of objects on the list of active objects.
1207 */
1208
1209int count_active(void) {
1210 int i=0;
1211 object *tmp=active_objects;
1212 while(tmp!=NULL)
1213 tmp=tmp->active_next, i++;
1214 return i;
1215} 966}
1216 967
1217/* 968/*
1218 * sub_weight() recursively (outwards) subtracts a number from the 969 * sub_weight() recursively (outwards) subtracts a number from the
1219 * weight of an object (and what is carried by it's environment(s)). 970 * weight of an object (and what is carried by it's environment(s)).
1297 /* we set up values so that it could be inserted into 1048 /* we set up values so that it could be inserted into
1298 * the map, but we don't actually do that - it is up 1049 * the map, but we don't actually do that - it is up
1299 * to the caller to decide what we want to do. 1050 * to the caller to decide what we want to do.
1300 */ 1051 */
1301 op->x=op->env->x,op->y=op->env->y; 1052 op->x=op->env->x,op->y=op->env->y;
1302 op->ox=op->x,op->oy=op->y;
1303 op->map=op->env->map; 1053 op->map=op->env->map;
1304 op->above=NULL,op->below=NULL; 1054 op->above=NULL,op->below=NULL;
1305 op->env=NULL; 1055 op->env=NULL;
1306 return; 1056 return;
1307 } 1057 }
1382 (op->move_type & ~tmp->move_off & ~tmp->move_block)==0)) { 1132 (op->move_type & ~tmp->move_off & ~tmp->move_block)==0)) {
1383 1133
1384 move_apply(tmp, op, NULL); 1134 move_apply(tmp, op, NULL);
1385 if (was_destroyed (op, tag)) { 1135 if (was_destroyed (op, tag)) {
1386 LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " 1136 LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed "
1387 "leaving object\n", tmp->name, tmp->arch->name); 1137 "leaving object\n", &tmp->name, &tmp->arch->name);
1388 } 1138 }
1389 } 1139 }
1390 1140
1391 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ 1141 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */
1392 1142
1518 * we set the map, that doesn't work if the location is within 1268 * we set the map, that doesn't work if the location is within
1519 * a map and this is straddling an edge. So only if coordinate 1269 * a map and this is straddling an edge. So only if coordinate
1520 * is clear wrong do we normalize it. 1270 * is clear wrong do we normalize it.
1521 */ 1271 */
1522 if (OUT_OF_REAL_MAP(more->map, more->x, more->y)) { 1272 if (OUT_OF_REAL_MAP(more->map, more->x, more->y)) {
1523 /* Debugging information so you can see the last coordinates this object had */
1524 more->ox = more->x;
1525 more->oy = more->y;
1526 more->map = get_map_from_coord(m, &more->x, &more->y); 1273 more->map = get_map_from_coord(m, &more->x, &more->y);
1527 } else if (!more->map) { 1274 } else if (!more->map) {
1528 /* For backwards compatibility - when not dealing with tiled maps, 1275 /* For backwards compatibility - when not dealing with tiled maps,
1529 * more->map should always point to the parent. 1276 * more->map should always point to the parent.
1530 */ 1277 */
1536 LOG (llevError, "BUG: insert_ob_in_map(): inserting op->more killed op\n"); 1283 LOG (llevError, "BUG: insert_ob_in_map(): inserting op->more killed op\n");
1537 return NULL; 1284 return NULL;
1538 } 1285 }
1539 } 1286 }
1540 CLEAR_FLAG(op,FLAG_REMOVED); 1287 CLEAR_FLAG(op,FLAG_REMOVED);
1541
1542 /* Debugging information so you can see the last coordinates this object had */
1543 op->ox=op->x;
1544 op->oy=op->y;
1545 1288
1546 /* Ideally, the caller figures this out. However, it complicates a lot 1289 /* Ideally, the caller figures this out. However, it complicates a lot
1547 * of areas of callers (eg, anything that uses find_free_spot would now 1290 * of areas of callers (eg, anything that uses find_free_spot would now
1548 * need extra work 1291 * need extra work
1549 */ 1292 */
1617 * looks like instead of lots of conditions here. 1360 * looks like instead of lots of conditions here.
1618 * makes things faster, and effectively the same result. 1361 * makes things faster, and effectively the same result.
1619 */ 1362 */
1620 1363
1621 /* Have object 'fall below' other objects that block view. 1364 /* Have object 'fall below' other objects that block view.
1622 * Unless those objects are exits, type 66 1365 * Unless those objects are exits, type 66
1623 * If INS_ON_TOP is used, don't do this processing 1366 * If INS_ON_TOP is used, don't do this processing
1624 * Need to find the object that in fact blocks view, otherwise 1367 * Need to find the object that in fact blocks view, otherwise
1625 * stacking is a bit odd. 1368 * stacking is a bit odd.
1626 */ 1369 */
1627 if (!(flag & INS_ON_TOP) && 1370 if (!(flag & INS_ON_TOP) &&
1628 (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && 1371 (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) &&
1629 (op->face && !op->face->visibility)) { 1372 (op->face && !op->face->visibility)) {
1630 for (last=top; last != floor; last=last->below) 1373 for (last=top; last != floor; last=last->below)
1631 if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; 1374 if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break;
1632 /* Check to see if we found the object that blocks view, 1375 /* Check to see if we found the object that blocks view,
1633 * and make sure we have a below pointer for it so that 1376 * and make sure we have a below pointer for it so that
1634 * we can get inserted below this one, which requires we 1377 * we can get inserted below this one, which requires we
1635 * set top to the object below us. 1378 * set top to the object below us.
1636 */ 1379 */
1665 1408
1666 /* If we have a floor, we know the player, if any, will be above 1409 /* If we have a floor, we know the player, if any, will be above
1667 * it, so save a few ticks and start from there. 1410 * it, so save a few ticks and start from there.
1668 */ 1411 */
1669 if (!(flag & INS_MAP_LOAD)) 1412 if (!(flag & INS_MAP_LOAD))
1670 for(tmp=floor?floor:GET_MAP_OB(op->map,op->x,op->y);tmp!=NULL;tmp=tmp->above) { 1413 for(tmp=floor?floor:GET_MAP_OB(op->map,op->x,op->y);tmp!=NULL;tmp=tmp->above) {
1671 if (tmp->type == PLAYER) 1414 if (tmp->type == PLAYER)
1672 tmp->contr->socket.update_look=1; 1415 tmp->contr->socket.update_look=1;
1673 } 1416 }
1674 1417
1675 /* If this object glows, it may affect lighting conditions that are 1418 /* If this object glows, it may affect lighting conditions that are
1676 * visible to others on this map. But update_all_los is really 1419 * visible to others on this map. But update_all_los is really
1677 * an inefficient way to do this, as it means los for all players 1420 * an inefficient way to do this, as it means los for all players
1678 * on the map will get recalculated. The players could very well 1421 * on the map will get recalculated. The players could very well
1750 object *newob; 1493 object *newob;
1751 int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); 1494 int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0);
1752 1495
1753 if(orig_ob->nrof<nr) { 1496 if(orig_ob->nrof<nr) {
1754 sprintf(errmsg,"There are only %d %ss.", 1497 sprintf(errmsg,"There are only %d %ss.",
1755 orig_ob->nrof?orig_ob->nrof:1, orig_ob->name); 1498 orig_ob->nrof?orig_ob->nrof:1, &orig_ob->name);
1756 return NULL; 1499 return NULL;
1757 } 1500 }
1758 newob = object_create_clone(orig_ob); 1501 newob = object_create_clone(orig_ob);
1759 if((orig_ob->nrof-=nr)<1) { 1502 if((orig_ob->nrof-=nr)<1) {
1760 if ( ! is_removed) 1503 if ( ! is_removed)
1907 "Warning: Tried to insert object wrong part of multipart object.\n"); 1650 "Warning: Tried to insert object wrong part of multipart object.\n");
1908 where = where->head; 1651 where = where->head;
1909 } 1652 }
1910 if (op->more) { 1653 if (op->more) {
1911 LOG(llevError, "Tried to insert multipart object %s (%d)\n", 1654 LOG(llevError, "Tried to insert multipart object %s (%d)\n",
1912 op->name, op->count); 1655 &op->name, op->count);
1913 return op; 1656 return op;
1914 } 1657 }
1915 CLEAR_FLAG(op, FLAG_OBJ_ORIGINAL); 1658 CLEAR_FLAG(op, FLAG_OBJ_ORIGINAL);
1916 CLEAR_FLAG(op, FLAG_REMOVED); 1659 CLEAR_FLAG(op, FLAG_REMOVED);
1917 if(op->nrof) { 1660 if(op->nrof) {
1951 op->map=NULL; 1694 op->map=NULL;
1952 op->env=where; 1695 op->env=where;
1953 op->above=NULL; 1696 op->above=NULL;
1954 op->below=NULL; 1697 op->below=NULL;
1955 op->x=0,op->y=0; 1698 op->x=0,op->y=0;
1956 op->ox=0,op->oy=0;
1957 1699
1958 /* reset the light list and los of the players on the map */ 1700 /* reset the light list and los of the players on the map */
1959 if((op->glow_radius!=0)&&where->map) 1701 if((op->glow_radius!=0)&&where->map)
1960 { 1702 {
1961#ifdef DEBUG_LIGHTS 1703#ifdef DEBUG_LIGHTS
2003{ 1745{
2004 object *tmp; 1746 object *tmp;
2005 tag_t tag; 1747 tag_t tag;
2006 mapstruct *m=op->map; 1748 mapstruct *m=op->map;
2007 int x=op->x, y=op->y; 1749 int x=op->x, y=op->y;
2008 MoveType move_on, move_slow, move_block; 1750 MoveType move_on, move_slow, move_block;
2009 1751
2010 if(QUERY_FLAG(op,FLAG_NO_APPLY)) 1752 if(QUERY_FLAG(op,FLAG_NO_APPLY))
2011 return 0; 1753 return 0;
2012 1754
2013 tag = op->count; 1755 tag = op->count;
2331int find_dir(mapstruct *m, int x, int y, object *exclude) { 2073int find_dir(mapstruct *m, int x, int y, object *exclude) {
2332 int i,max=SIZEOFFREE, mflags; 2074 int i,max=SIZEOFFREE, mflags;
2333 sint16 nx, ny; 2075 sint16 nx, ny;
2334 object *tmp; 2076 object *tmp;
2335 mapstruct *mp; 2077 mapstruct *mp;
2336 MoveType blocked, move_type; 2078 MoveType blocked, move_type;
2337 2079
2338 if (exclude && exclude->head) { 2080 if (exclude && exclude->head) {
2339 exclude = exclude->head; 2081 exclude = exclude->head;
2340 move_type = exclude->move_type; 2082 move_type = exclude->move_type;
2341 } else { 2083 } else {
2633 fclose(tempfile); 2375 fclose(tempfile);
2634 2376
2635 op=get_object(); 2377 op=get_object();
2636 2378
2637 object_thawer thawer (filename); 2379 object_thawer thawer (filename);
2380
2638 if (thawer) 2381 if (thawer)
2639 load_object(thawer,op,LO_NEWFILE,0); 2382 load_object(thawer,op,0);
2383
2640 LOG(llevDebug," load str completed, object=%s\n",op->name); 2384 LOG(llevDebug," load str completed, object=%s\n", &op->name);
2641 CLEAR_FLAG(op,FLAG_REMOVED); 2385 CLEAR_FLAG(op,FLAG_REMOVED);
2642 2386
2643 return op; 2387 return op;
2644} 2388}
2645 2389
2684 */ 2428 */
2685const char * get_ob_key_value(const object * op, const char * const key) { 2429const char * get_ob_key_value(const object * op, const char * const key) {
2686 key_value * link; 2430 key_value * link;
2687 const char * canonical_key; 2431 const char * canonical_key;
2688 2432
2689 canonical_key = find_string(key); 2433 canonical_key = shstr::find (key);
2690 2434
2691 if (canonical_key == NULL) { 2435 if (canonical_key == NULL) {
2692 /* 1. There being a field named key on any object 2436 /* 1. There being a field named key on any object
2693 * implies there'd be a shared string to find. 2437 * implies there'd be a shared string to find.
2694 * 2. Since there isn't, no object has this field. 2438 * 2. Since there isn't, no object has this field.
2717 * Unless add_key is TRUE, it won't add fields, only change the value of existing 2461 * Unless add_key is TRUE, it won't add fields, only change the value of existing
2718 * keys. 2462 * keys.
2719 * 2463 *
2720 * Returns TRUE on success. 2464 * Returns TRUE on success.
2721 */ 2465 */
2722int set_ob_key_value_s(object * op, const char * canonical_key, const char * value, int add_key) { 2466int set_ob_key_value_s(object * op, const shstr &canonical_key, const char * value, int add_key) {
2723 key_value * field = NULL, *last=NULL; 2467 key_value * field = NULL, *last=NULL;
2724 2468
2725 for (field=op->key_values; field != NULL; field=field->next) { 2469 for (field=op->key_values; field != NULL; field=field->next) {
2726 if (field->key != canonical_key) { 2470 if (field->key != canonical_key) {
2727 last = field; 2471 last = field;
2728 continue; 2472 continue;
2729 } 2473 }
2730 2474
2731 if (field->value) FREE_AND_CLEAR_STR(field->value);
2732 if (value) 2475 if (value)
2733 field->value = add_string(value); 2476 field->value = value;
2734 else { 2477 else {
2735 /* Basically, if the archetype has this key set, 2478 /* Basically, if the archetype has this key set,
2736 * we need to store the null value so when we save 2479 * we need to store the null value so when we save
2737 * it, we save the empty value so that when we load, 2480 * it, we save the empty value so that when we load,
2738 * we get this value back again. 2481 * we get this value back again.
2739 */ 2482 */
2740 if (get_ob_key_link(&op->arch->clone, canonical_key)) 2483 if (get_ob_key_link (&op->arch->clone, canonical_key))
2741 field->value = NULL; 2484 field->value = 0;
2742 else { 2485 else
2743 /* Delete this link */ 2486 {
2744 if (field->key) FREE_AND_CLEAR_STR(field->key);
2745 if (field->value) FREE_AND_CLEAR_STR(field->value);
2746 if (last) last->next = field->next; 2487 if (last) last->next = field->next;
2747 else op->key_values = field->next; 2488 else op->key_values = field->next;
2489
2748 free(field); 2490 delete field;
2749 } 2491 }
2750 } 2492 }
2751 return TRUE; 2493 return TRUE;
2752 } 2494 }
2753 /* IF we get here, key doesn't exist */ 2495 /* IF we get here, key doesn't exist */
2754 2496
2763 * be here. If user wants to store empty strings, 2505 * be here. If user wants to store empty strings,
2764 * should pass in "" 2506 * should pass in ""
2765 */ 2507 */
2766 if (value == NULL) return TRUE; 2508 if (value == NULL) return TRUE;
2767 2509
2768 field = (key_value *) malloc(sizeof(key_value)); 2510 field = new key_value;
2769 2511
2770 field->key = add_refcount(canonical_key); 2512 field->key = canonical_key;
2771 field->value = add_string(value); 2513 field->value = value;
2772 /* Usual prepend-addition. */ 2514 /* Usual prepend-addition. */
2773 field->next = op->key_values; 2515 field->next = op->key_values;
2774 op->key_values = field; 2516 op->key_values = field;
2775 2517
2776 return TRUE; 2518 return TRUE;
2783 * and not add new ones. 2525 * and not add new ones.
2784 * In general, should be little reason FALSE is ever passed in for add_key 2526 * In general, should be little reason FALSE is ever passed in for add_key
2785 * 2527 *
2786 * Returns TRUE on success. 2528 * Returns TRUE on success.
2787 */ 2529 */
2788int set_ob_key_value(object * op, const char * key, const char * value, int add_key) { 2530int set_ob_key_value(object * op, const char *key, const char * value, int add_key)
2789 const char * canonical_key = NULL; 2531{
2790 int floating_ref = FALSE; 2532 shstr key_ (key);
2791 int ret;
2792
2793 /* HACK This mess is to make sure set_ob_value() passes a shared string
2794 * to get_ob_key_link(), without leaving a leaked refcount.
2795 */
2796
2797 canonical_key = find_string(key);
2798 if (canonical_key == NULL) {
2799 canonical_key = add_string(key);
2800 floating_ref = TRUE;
2801 }
2802
2803 ret = set_ob_key_value_s(op, canonical_key, value, add_key); 2533 return set_ob_key_value_s (op, key_, value, add_key);
2804
2805 if (floating_ref) {
2806 free_string(canonical_key);
2807 }
2808
2809 return ret;
2810} 2534}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines