Changeset c232af in git for Singular/ipid.cc
- Timestamp:
- Aug 14, 2000, 2:58:28 PM (24 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- d26c2e9dd38f1531c0e77c38e6177109182b5bca
- Parents:
- 4697a8a1ccbf49d0048033ea29c651e3966ba729
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ipid.cc
r4697a8a rc232af 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipid.cc,v 1.4 0 2000-05-23 14:33:24 SingularExp $ */4 /* $Id: ipid.cc,v 1.41 2000-08-14 12:56:24 obachman Exp $ */ 5 5 6 6 /* … … 11 11 12 12 #include "mod2.h" 13 #include <omalloc.h> 13 14 #include "tok.h" 14 15 #include "ipshell.h" 15 16 #include "intvec.h" 16 17 #include "febase.h" 17 #include "mmemory.h"18 18 #include "numbers.h" 19 19 #include "polys.h" … … 27 27 #include "ipid.h" 28 28 29 30 omBin sip_command_bin = omGetSpecBin(sizeof(sip_command)); 31 omBin ip_command_bin = omGetSpecBin(sizeof(ip_command)); 32 omBin sip_package_bin = omGetSpecBin(sizeof(sip_package)); 33 omBin ip_package_bin = omGetSpecBin(sizeof(ip_package)); 34 omBin idrec_bin = omGetSpecBin(sizeof(idrec)); 35 omBin namerec_bin = omGetSpecBin(sizeof(namerec)); 36 29 37 namehdl namespaceroot = NULL; 30 38 #define TEST … … 35 43 ring currRing = NULL; 36 44 ideal currQuotient = NULL; 45 omBin currPolyBin = NULL; 37 46 char* iiNoName="_"; 38 47 … … 52 61 while (h!=NULL) 53 62 { 54 mmTestLP(IDID(h));63 omCheckAddr(IDID(h)); 55 64 // ============================================================= 56 65 #if 0 … … 111 120 // if (id!=NULL) 112 121 // { 113 // FreeL((ADDRESS)id);122 // omFree((ADDRESS)id); 114 123 // id=NULL; 115 124 // } … … 120 129 { 121 130 //printf("define %s, %x, lev: %d, typ: %d\n", s,s,lev,t); 122 idhdl h = (idrec *) Alloc0SizeOf(idrec);131 idhdl h = (idrec *)omAlloc0Bin(idrec_bin); 123 132 int len = 0; 124 133 IDID(h) = s; … … 133 142 switch (t) 134 143 { 135 //the type with init routines:144 //the type with init routines: 136 145 case INTVEC_CMD: 137 146 case INTMAT_CMD: 138 IDINTVEC(h) = NewIntvec0();147 IDINTVEC(h) = new intvec(); 139 148 break; 140 149 case NUMBER_CMD: … … 149 158 case MAP_CMD: 150 159 IDIDEAL(h) = idInit(1,1); 151 IDMAP(h)->preimage = mstrdup(IDID(currRingHdl));160 IDMAP(h)->preimage = omStrDup(IDID(currRingHdl)); 152 161 break; 153 162 case STRING_CMD: 154 IDSTRING(h) = mstrdup("");163 IDSTRING(h) = omStrDup(""); 155 164 break; 156 165 case LIST_CMD: 157 IDLIST(h)=(lists) AllocSizeOf(slists);166 IDLIST(h)=(lists)omAllocBin(slists_bin); 158 167 IDLIST(h)->Init(); 159 168 break; 160 //the types with the standard init: set the struct to zero161 169 case LINK_CMD: 162 len=sizeof(ip_link);170 IDLINK(h)=(si_link) omAlloc0Bin(sip_link_bin); 163 171 break; 164 172 case RING_CMD: 165 173 case QRING_CMD: 166 len = sizeof(ip_sring);174 IDRING(h) = (ring) omAlloc0Bin(sip_sring_bin); 167 175 break; 168 176 case PACKAGE_CMD: 169 len = sizeof(ip_package); 170 break; 177 IDPACKAGE(h) = (package) omAlloc0Bin(sip_package_bin); 178 break; 179 case PROC_CMD: 180 IDPROC(h) = (procinfo*) omAlloc0Bin(procinfo_bin); 181 break; 182 //the types with the standard init: set the struct to zero 171 183 case RESOLUTION_CMD: 172 184 len=sizeof(ssyStrategy); 173 185 break; 174 case PROC_CMD:175 len=sizeof(procinfo);176 break;177 186 //other types: without init (int,script,poly,def,package) 178 187 } 179 188 if (len!=0) 180 189 { 181 IDSTRING(h) = (char *) Alloc0(len);190 IDSTRING(h) = (char *)omAlloc0(len); 182 191 } 183 192 // additional settings:-------------------------------------- … … 196 205 IDPACKAGE(h)->loaded = FALSE; 197 206 } 198 199 207 } 200 208 // -------------------------------------------------------- … … 224 232 &&(s==IDID(currRingHdl))) 225 233 { 226 s= mstrdup(s);234 s=omStrDup(s); 227 235 } 228 236 // is it already defined in root ? … … 231 239 if (IDLEV(h)!=lev) 232 240 { 233 s= mstrdup(s);241 s=omStrDup(s); 234 242 } 235 243 else if ((IDTYP(h) == t)||(t==DEF_CMD)) … … 261 269 if (IDLEV(h)!=lev) 262 270 { 263 s= mstrdup(s);271 s=omStrDup(s); 264 272 } 265 273 else if ((IDTYP(h) == t)||(t==DEF_CMD)) … … 286 294 if ((h=topnsroot->get(s,lev))!=NULL) 287 295 { 288 s= mstrdup(s);296 s=omStrDup(s); 289 297 } 290 298 } … … 297 305 if (IDLEV(h)!=lev) 298 306 { 299 s= mstrdup(s);307 s=omStrDup(s); 300 308 } 301 309 else if ((IDTYP(h) == t)||(t==DEF_CMD)) … … 402 410 /* no complete init*/ 403 411 } 412 else 413 { 414 // we are killing the basering, so: make sure that 415 // sLastPrinted is killed before this ring is destroyed 416 if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) 417 || ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data)))) 418 { 419 sLastPrinted.CleanUp(); 420 memset(&sLastPrinted,0,sizeof(sleftv)); 421 } 422 } 404 423 while (hdh!=NULL) 405 424 { … … 468 487 { 469 488 map im = IDMAP(h); 470 FreeL((ADDRESS)im->preimage);489 omFree((ADDRESS)im->preimage); 471 490 } 472 491 idDelete(&iid); … … 475 494 else if (IDTYP(h) == STRING_CMD) 476 495 { 477 FreeL((ADDRESS)IDSTRING(h));496 omFree((ADDRESS)IDSTRING(h)); 478 497 //IDSTRING(h)=NULL; 479 498 } … … 497 516 { 498 517 IDLIST(h)->Clean(); 499 // Free((ADDRESS)IDLIST(h)->m, (IDLIST(h)->nr+1)*sizeof(sleftv));500 // FreeSizeOf((ADDRESS)IDLIST(h), slists);518 //omFreeSize((ADDRESS)IDLIST(h)->m, (IDLIST(h)->nr+1)*sizeof(sleftv)); 519 //omFreeBin((ADDRESS)IDLIST(h), slists_bin); 501 520 } 502 521 // link ------------------------------------------------------------- … … 523 542 #endif 524 543 525 FreeL((ADDRESS)IDID(h)); 544 if (IDID(h)) // OB: ????? 545 omFree((ADDRESS)IDID(h)); 526 546 //IDID(h)=NULL; 527 547 if (h == (*ih)) … … 545 565 } 546 566 } 547 FreeSizeOf((ADDRESS)h,idrec);567 omFreeBin((ADDRESS)h, idrec_bin); 548 568 } 549 569 … … 624 644 while (h!=NULL) { l++; h=IDNEXT(h); } 625 645 /* allocate list */ 626 lists L=(lists) AllocSizeOf(slists);646 lists L=(lists)omAllocBin(slists_bin); 627 647 L->Init(l); 628 648 /* copy names */ … … 633 653 /* list is initialized with 0 => no need to clear anything */ 634 654 L->m[l].rtyp=STRING_CMD; 635 L->m[l].data= mstrdup(IDID(h));655 L->m[l].data=omStrDup(IDID(h)); 636 656 l++; 637 657 h=IDNEXT(h); … … 700 720 char p[8]; 701 721 sprintf(p, "%d", pi->ref); 702 return mstrdup(p); // MEMORY-LEAK722 return omStrDup(p); // MEMORY-LEAK 703 723 } 704 724 return "??"; … … 710 730 if (pi->ref <= 0) 711 731 { 712 FreeL((ADDRESS)pi->libname); 713 FreeL((ADDRESS)pi->procname); 732 if (pi->libname != NULL) // OB: ???? 733 omFree((ADDRESS)pi->libname); 734 if (pi->procname != NULL) // OB: ???? 735 omFree((ADDRESS)pi->procname); 736 714 737 if( pi->language == LANG_SINGULAR) 715 738 { 716 FreeL((ADDRESS)pi->data.s.body); 739 if (pi->data.s.body != NULL) // OB: ???? 740 omFree((ADDRESS)pi->data.s.body); 717 741 } 718 742 if( pi->language == LANG_C) … … 738 762 piCleanUp(pi); 739 763 if (pi->ref <= 0) 740 FreeSizeOf((ADDRESS)pi, procinfo);764 omFreeBin((ADDRESS)pi, procinfo_bin); 741 765 return FALSE; 742 766 } … … 755 779 #endif /* HAVE_DYNAMIC_LOADING */ 756 780 } 757 FreeL((ADDRESS)pack->libname);781 omFree((ADDRESS)pack->libname); 758 782 memset((void *) pack, 0, sizeof(sip_package)); 759 783 pack->language=LANG_NONE; … … 779 803 if(checkPackage(pack)) { 780 804 paCleanUp(pack); 781 FreeSizeOf((ADDRESS)pack, sip_package);805 omFreeBin((ADDRESS)pack, sip_package_bin); 782 806 } else return FALSE; 783 807 } else paCleanUp(pack); … … 788 812 char *idhdl2id(idhdl pck, idhdl h) 789 813 { 790 char *name = (char *) AllocL(strlen(pck->id) + strlen(h->id) + 3);814 char *name = (char *)omAlloc(strlen(pck->id) + strlen(h->id) + 3); 791 815 sprintf(name, "%s::%s", pck->id, h->id); 792 816 return(name); … … 800 824 if(q==NULL) 801 825 { 802 p = mstrdup("");803 i = (char *) AllocL(strlen(name)+1);826 p = omStrDup(""); 827 i = (char *)omAlloc(strlen(name)+1); 804 828 *i = '\0'; 805 829 sscanf(name, "%s", i); … … 812 836 else { 813 837 if( *(q+1) != ':') return; 814 i = (char *) AllocL(strlen(name)+1);838 i = (char *)omAlloc(strlen(name)+1); 815 839 *i = '\0'; 816 840 if(name == q) 817 841 { 818 p = mstrdup("");842 p = omStrDup(""); 819 843 sscanf(name, "::%s", i); 820 844 #ifdef HAVE_NAMESPACES … … 825 849 else 826 850 { 827 p = (char *) AllocL(strlen(name)+1);851 p = (char *)omAlloc(strlen(name)+1); 828 852 sscanf(name, "%[^:]::%s", p, i); 829 853 #ifdef HAVE_NAMESPACES … … 838 862 //printf("Package: '%s'\n", p); 839 863 //printf("Id Rec : '%s'\n", i); 840 FreeL(p);841 FreeL(i);864 omFree(p); 865 omFree(i); 842 866 } 843 867 … … 855 879 { 856 880 //printf("PUSH: put entry (%s) on stack\n", name); 857 namehdl ns = (namerec *) Alloc0SizeOf(namerec);881 namehdl ns = (namerec *)omAlloc0Bin(namerec_bin); 858 882 extern int myynest; 859 883 if(nesting<0) nesting = myynest; … … 868 892 ns->next = NULL; 869 893 #ifdef HAVE_NAMESPACES 870 ns->pack = (ip_package *) Alloc0SizeOf(ip_package);894 ns->pack = (ip_package *)omAlloc0Bin(ip_package_bin); 871 895 #endif /* HAVE_NAMESPACES */ 872 896 ns->isroot = TRUE; … … 885 909 //printf("Saving Ring %x, %x\n", this->currRing, currRing); 886 910 } 887 ns->name = mstrdup(name);911 ns->name = omStrDup(name); 888 912 ns->myynest = nesting; 889 913 … … 894 918 #if 0 895 919 if(init && ns->isroot) { 896 idhdl pl = enterid( mstrdup("Top"),0, PACKAGE_CMD,920 idhdl pl = enterid( omStrDup("Top"),0, PACKAGE_CMD, 897 921 &NSROOT(namespaceroot), TRUE ); 898 922 if(pl != NULL) { 899 FreeSizeOf((ADDRESS)IDPACKAGE(pl), ip_package);923 omFreeBin((ADDRESS)IDPACKAGE(pl), ip_package_bin); 900 924 IDPACKAGE(pl) = ns->pack; 901 925 } … … 920 944 ns = this; 921 945 namespaceroot = this->next; 922 FreeL((ADDRESS)ns->name);923 FreeSizeOf((ADDRESS)ns, namerec);946 omFree((ADDRESS)ns->name); 947 omFreeBin((ADDRESS)ns, namerec_bin); 924 948 return(namespaceroot); 925 949 }
Note: See TracChangeset
for help on using the changeset viewer.