Changeset b335e35 in git
- Timestamp:
- Jan 17, 2022, 2:16:09 PM (17 months ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 4c1b5d9a51feb5ce7896c89dcb0b4db3768454fb
- Parents:
- 2d5c1931cd9af26341282db39ce50f9e5ae279ff
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/ideals.cc
r2d5c19 rb335e35 1734 1734 block1[k+1] = origR->block1[k]; 1735 1735 ord[k+1] = origR->order[k]; 1736 if (origR->wvhdl[k]!=NULL) wv[k+1] = (int*) omMemDup(origR->wvhdl[k]); 1736 if (origR->wvhdl[k]!=NULL) 1737 #ifdef HAVE_OMALLOC 1738 wv[k+1] = (int*) omMemDup(origR->wvhdl[k]); 1739 #else 1740 { 1741 int l=(origR->block1[k]-origR->block0[k]+1)*sizeof(int); 1742 wv[k+1]=(int*)omalloc(l); 1743 memcpy(wv[k+1],origR->wvhdl[k],l); 1744 } 1745 #endif 1737 1746 } 1738 1747 block0[0] = 1; -
libpolys/polys/monomials/ring.cc
r2d5c19 rb335e35 982 982 tmpR.order[1]=r2->order[0]; 983 983 if (r2->wvhdl[0]!=NULL) 984 #ifdef HAVE_OMALLOC 984 985 tmpR.wvhdl[1]=(int *)omMemDup(r2->wvhdl[0]); 986 #else 987 { 988 int l=(r2->block1[0]-r2->block0[0]+1)*sizeof(int); 989 tmpR.wvhdl[1]=(int*)omalloc(l); 990 memcpy(tmpR.wvhdl[1],r2->wvhdl[0],l); 991 } 992 #endif 985 993 } 986 994 else … … 1060 1068 tmpR.block1[i]=r1->block1[i]; 1061 1069 if (r1->wvhdl[i]!=NULL) 1070 #ifdef HAVE_OMALLOC 1062 1071 tmpR.wvhdl[i] = (int*) omMemDup(r1->wvhdl[i]); 1072 #else 1073 { 1074 int l=(r1->block1[i]-r1->block0[i]+1)*sizeof(int); 1075 tmpR.wvhdl[i]=(int*)omalloc(l); 1076 memcpy(tmpR.wvhdl[i],r1->wvhdl[i],l); 1077 } 1078 #endif 1063 1079 } 1064 1080 j=i; … … 1080 1096 if (r2->wvhdl[i]!=NULL) 1081 1097 { 1098 #ifdef HAVE_OMALLOC 1082 1099 tmpR.wvhdl[j] = (int*) omMemDup(r2->wvhdl[i]); 1100 #else 1101 { 1102 int l=(r2->block1[i]-r2->block0[i]+1)*sizeof(int); 1103 tmpR.wvhdl[j]=(int*)omalloc(l); 1104 memcpy(tmpR.wvhdl[j],r2->wvhdl[i],l); 1105 } 1106 #endif 1083 1107 } 1084 1108 j++; … … 1107 1131 if (r1->wvhdl[i]!=NULL) 1108 1132 { 1133 #ifdef HAVE_OMALLOC 1109 1134 tmpR.wvhdl[i] = (int*) omMemDup(r1->wvhdl[i]); 1135 #else 1136 { 1137 int l=(r1->block1[i]-r1->block0[i]+1)*sizeof(int); 1138 tmpR.wvhdl[i]=(int*)omalloc(l); 1139 memcpy(tmpR.wvhdl[i],r1->wvhdl[i],l); 1140 } 1141 #endif 1110 1142 } 1111 1143 } … … 1447 1479 if (r->wvhdl[j]!=NULL) 1448 1480 { 1481 #ifdef HAVE_OMALLOC 1449 1482 res->wvhdl[j] = (int*) omMemDup(r->wvhdl[j]); 1483 #else 1484 { 1485 int l=(r->block1[j]-r->block0[j]+1)*sizeof(int); 1486 res->wvhdl[j]=(int*)omalloc(l); 1487 memcpy(res->wvhdl[j],r->wvhdl[j],l); 1488 } 1489 #endif 1450 1490 } 1451 1491 else … … 1577 1617 if (r->wvhdl[j]!=NULL) 1578 1618 { 1619 #ifdef HAVE_OMALLOC 1579 1620 res->wvhdl[j+1] = (int*) omMemDup(r->wvhdl[j]); //DIFF 1621 #else 1622 { 1623 int l=(r->block1[j]-r->block0[j]+1)*sizeof(int); 1624 res->wvhdl[j+1]=(int*)omalloc(l); 1625 memcpy(res->wvhdl[j+1],r->wvhdl[j],l); 1626 } 1627 #endif 1580 1628 } 1581 1629 else … … 2239 2287 2240 2288 static void rO_WDegree64(int &place, int &bitplace, int start, int end, 2241 long *o, sro_ord &ord_struct, int 64*weights)2289 long *o, sro_ord &ord_struct, int *weights) 2242 2290 { 2243 2291 // weighted degree (aligned) of variables v_start..v_end, ordsgn 1, … … 2248 2296 ord_struct.data.wp64.end=end; 2249 2297 ord_struct.data.wp64.place=place; 2250 ord_struct.data.wp64.weights64=weights; 2298 int l=end-start+1; 2299 ord_struct.data.wp64.weights64=(int64*)omAlloc(l*sizeof(int64)); 2300 for(int i=0;i<l;i++) ord_struct.data.wp64.weights64[i]=weights[i]; 2251 2301 o[place]=1; 2252 2302 place++; … … 2400 2450 2401 2451 static void rO_ISPrefix(int &place, int &bitplace, int &prev_ord, 2402 long *o, int /*N*/, int *v, sro_ord &ord_struct)2452 long *o, int N, int *v, sro_ord &ord_struct) 2403 2453 { 2404 2454 if ((prev_ord== 1) || (bitplace!=BITS_PER_LONG)) … … 2408 2458 ord_struct.ord_typ = ro_isTemp; 2409 2459 ord_struct.data.isTemp.start = place; 2460 #ifdef HAVE_OMALLOC 2410 2461 ord_struct.data.isTemp.pVarOffset = (int *)omMemDup(v); 2462 #else 2463 ord_struct.data.isTemp.pVarOffset = (int *)omAlloc((N+1)*sizeof(int)); 2464 memcpy(ord_struct.data.isTemp.pVarOffset,v,(N+1)*sizeof(int)); 2465 #endif 2411 2466 ord_struct.data.isTemp.suffixpos = -1; 2412 2467 … … 3443 3498 case ringorder_a64: 3444 3499 rO_WDegree64(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 3445 tmp_typ[typ_i], (int64 *)(r->wvhdl[i]));3500 tmp_typ[typ_i], r->wvhdl[i]); 3446 3501 typ_i++; 3447 3502 break; … … 4181 4236 int l; 4182 4237 for(l=r->typ[j].data.wp64.start;l<=r->typ[j].data.wp64.end;l++) 4183 Print(" %ld",(long)( ((int64*)r->typ[j].data.wp64.weights64)+l-r->typ[j].data.wp64.start));4238 Print(" %ld",(long)(r->typ[j].data.wp64.weights64+l-r->typ[j].data.wp64.start); 4184 4239 } 4185 4240 } … … 4442 4497 if (r->wvhdl[j-1] != NULL) 4443 4498 { 4499 #ifdef HAVE_OMALLOC 4444 4500 wvhdl[j] = (int*) omMemDup(r->wvhdl[j-1]); 4501 #else 4502 { 4503 int l=(r->block1[j-1]-r->block0[j-1]+1)*sizeof(int); 4504 wvhdl[j]=(int*)omalloc(l); 4505 memcpy(wvhdl[j],r->wvhdl[j-1],l); 4506 } 4507 #endif 4445 4508 } 4446 4509 } … … 4620 4683 if (r->wvhdl[j]!=NULL) 4621 4684 { 4685 #ifdef HAVE_OMALLOC 4622 4686 new_r->wvhdl[j] = (int*) omMemDup(r->wvhdl[j]); 4687 #else 4688 { 4689 int l=(r->block1[j]-r->block0[j]+1)*sizeof(int); 4690 new_r->wvhdl[j]=(int*)omalloc(l); 4691 memcpy(new_r->wvhdl[j],r->wvhdl[j],l); 4692 } 4693 #endif 4623 4694 } 4624 4695 } … … 4844 4915 if (r->wvhdl[i] != NULL) 4845 4916 { 4917 #ifdef HAVE_OMALLOC 4846 4918 wvhdl[j] = (int*) omMemDup(r->wvhdl[i]); 4919 #else 4920 { 4921 int l=(r->block1[i]-r->block0[i]+1)*sizeof(int); 4922 wvhdl[j]=(int*)omalloc(l); 4923 memcpy(wvhdl[j],r->wvhdl[i],l); 4924 } 4925 #endif 4847 4926 } // else wvhdl[j] = NULL; 4848 4927 } … … 5188 5267 int i=0; 5189 5268 while((r->typ[i].ord_typ!=ro_wp64) && (r->typ[i].ord_typ>0)) i++; 5190 assume(r->typ[i].ord_typ==ro_wp64);5191 return (int64*)(r->typ[i].data.wp64.weights64);5269 if (r->typ[i].ord_typ!=ro_wp64) return NULL; /* should not happen*/ 5270 return r->typ[i].data.wp64.weights64; 5192 5271 } 5193 5272 -
libpolys/reporter/s_buff.cc
r2d5c19 rb335e35 241 241 if (str_p>=str_l) 242 242 { 243 int old_str_l=str_l; 243 244 str_l=str_l*2; 244 str=(char*)omRealloc0(str,str_l); 245 str=(char*)omRealloc(str,str_l); 246 memset(str+old_str_l,0,old_str_l); 245 247 } 246 248 c=s_getc(F); -
omalloc/xalloc.h
r2d5c19 rb335e35 13 13 #include <string.h> 14 14 #include "omalloc/omConfig.h" 15 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)16 #ifdef HAVE_MALLOC_H17 #include <malloc.h>18 #elif defined(HAVE_MALLOC_MALLOC_H)19 #include <malloc/malloc.h>20 #endif21 #endif22 15 #ifdef __cplusplus 23 16 extern "C" { … … 85 78 extern int om_sing_opt_show_mem; 86 79 87 static inline void * omalloc(size_t s) 88 { if (s!=0) 89 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) 90 { return malloc(s); } 91 #else 92 {long *d=(long*)malloc(s+sizeof(long)); *d=s;d++;return d; } 93 #endif 94 else return NULL; 95 } 96 static inline void * omAlloc(size_t s) 97 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) 98 { return malloc(s); } 99 #else 100 { long *d=(long*)malloc(s+sizeof(long)); *d=s;d++;return d; } 101 #endif 80 #define omalloc(s) malloc(s) 81 #define omAlloc(s) malloc(s) 82 102 83 static inline void * omAlloc0(size_t s) 103 84 { void *d=omAlloc(s);memset(d,0,s); return d; } … … 108 89 { if (d==NULL) return omAlloc(ns); 109 90 else 110 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)111 91 return realloc(d,ns); 112 #else113 {114 long *dd=(long*)d; dd--; dd=(long*)realloc(dd,ns+sizeof(long));115 *dd=ns+sizeof(long);dd++; return dd;116 }117 #endif118 92 } 119 93 #define omReallocAligned(A,B) omRealloc(A,B) … … 121 95 { if (d==NULL) return omAlloc(ns); 122 96 else 123 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)124 97 return realloc(d,ns); 125 #else 126 { 127 long *dd=(long*)d; dd--; dd=(long*)realloc(dd,ns+sizeof(long)); 128 *dd=ns+sizeof(long);dd++; return dd; 129 } 130 #endif 131 } 132 static inline long omSizeOfAddr(void *d) 133 #ifdef HAVE_MALLOC_USABLE_SIZE 134 { return malloc_usable_size(d); } 135 #elif defined(HAVE_AMLLOC_SIZE) 136 { return malloc_size(d); } 137 #else 138 { long *dd=(long*)d; dd--; return *dd;} 139 #endif 140 141 static inline void omfree(void *d) 142 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) 143 { free(d); } 144 #else 145 { if (d!=NULL) { long *dd=(long*)d; dd--; free(dd);}} 146 #endif 147 148 static inline void omFree(void *d) 149 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) 150 { free(d); } 151 #else 152 { long *dd=(long*)d; dd--; free(dd);} 153 #endif 154 155 static inline void *omRealloc0(void *d, size_t ns) 156 { 157 #ifdef HAVE_MALLOC_USABLE_SIZE 158 size_t os=0; 159 if (d!=NULL) os=malloc_usable_size(d); 160 if (os>=ns) 161 { 162 void *n=realloc(d,ns); 163 return n; 164 } 98 } 99 100 static inline void *omRealloc0Size(void *d, __attribute__((unused)) size_t os, size_t ns) 101 { if (d==NULL) 102 return omAlloc0(ns); 165 103 else 166 104 { 167 char * n=(char*)realloc(d,ns);168 memset(n+(ns-os),0,ns-os);169 return (void*) n;105 char *p=(char *)realloc(d,ns); 106 if (ns>os) memset(p+os,0,ns-os); 107 return (void*)p; 170 108 } 171 #elif defined(HAVE_MALLOC_SIZE) 172 size_t os=0; 173 if (d!=NULL) os=malloc_size(d); 174 if (os>=ns) 175 { 176 void *n=realloc(d,ns); 177 return n; 178 } 179 else 180 { 181 char *n=(char*)realloc(d,ns); 182 memset(n+(ns-os),0,ns-os); 183 return (void*)n; 184 } 185 #else 186 void *n=omAlloc0(ns); 187 if (d!=NULL) 188 { 189 size_t c; 190 size_t os=omSizeOfAddr(d); 191 if (ns>os) c=os; else c=ns; 192 memcpy(n,d,c); 193 omFree(d); 194 } 195 return n; 196 #endif 197 } 198 static inline void omFreeSize(void *d, __attribute__((unused)) size_t s) 199 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) 200 { free(d); } 201 #else 202 { if (d!=NULL) { long *dd=(long*)d; dd--; free(dd);}} 203 #endif 109 } 110 111 #define omfree(d) free(d) 112 #define omFree(d) free(d) 113 #define omFreeSize(d,s) free(d) 204 114 205 115 static inline char * omStrDup(const char *s) … … 207 117 return strcpy(ns,s); 208 118 } 209 static inline void * omMemDup(void * s)210 #ifdef HAVE_MALLOC_USABLE_SIZE211 { size_t l=malloc_usable_size(s);212 void *n=malloc(l);213 memcpy(n,s,l);214 return n;215 }216 #elif defined(HAVE_MALLOC_SIZE)217 { size_t l=malloc_size(s);218 void *n=malloc(l);219 memcpy(n,s,l);220 return n;221 }222 #else223 { long *n;long *d=(long*)s; d--;224 n=(long*)malloc(*d+sizeof(long));225 memcpy(n,d,(*d)+sizeof(long));226 n++;227 return n;228 }229 #endif230 119 231 120 /* #define omSizeWOfBin(bin_ptr) ((bin_ptr)->sizeW) */ … … 290 179 #define omrealloc(A,NS) omRealloc(A,NS) 291 180 #define omreallocSize(A,OS,NS) omRealloc(A,NS) 292 #define omRealloc0Size(A,OS,NS) omRealloc0(A,NS) 293 #define omrealloc0Size(A,OS,NS) omRealloc0(A,NS) 181 #define omrealloc0Size(A,OS,NS) omRealloc0Size(A,OS,NS) 294 182 #define omMarkAsStaticAddr(A) 295 #define omMemCpyW(A,B,S) memcpy(A,B,(S)<<2)296 #define omMemcpyW(A,B,S) memcpy(A,B,(S)<<2)297 183 #define omGetSpecBin(A) (A) 298 184 #define omUnGetSpecBin(A) do {} while (0) 299 #define memcpyW(A,B,C) memcpy(A,B,(C)*sizeof(long))300 #define omGetStickyBinOfBin(B) omGetSpecBin(B)185 #define omMemcpyW(A,B,C) memcpy(A,B,(C)*sizeof(long)) 186 #define omGetStickyBinOfBin(B) omGetSpecBin(B) 301 187 302 188
Note: See TracChangeset
for help on using the changeset viewer.