Differences From Artifact [2700645c79]:
- File
src/editing.mm
— part of check-in
[489124a92f]
at
2025-03-16 10:11:39
on branch trunk
— Use one autorelease pool per frame
This way, nowhere else autorelease pools need to be managed. (user: js, size: 12473) [annotate] [blame] [check-ins using]
To Artifact [8eeba4e2ca]:
- File src/editing.mm — part of check-in [08c9d7b0fa] at 2025-03-20 17:12:11 on branch trunk — Remove last usage of vector (user: js, size: 12751) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
235 236 237 238 239 240 241 | if (selset) { linestyle(GRIDS, 0xFF, 0x40, 0x40); box(sel, (float)selh, (float)selh, (float)selh, (float)selh); } } | | | > | | | | | > > > > > > | > | | > | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | if (selset) { linestyle(GRIDS, 0xFF, 0x40, 0x40); box(sel, (float)selh, (float)selh, (float)selh, (float)selh); } } static OFMutableData *undos; // unlimited undo VARP(undomegs, 0, 1, 10); // bounded by n megs void pruneundos(int maxremain) // bound memory { int t = 0; for (ssize_t i = (ssize_t)undos.count - 1; i >= 0; i--) { block *undo = *(block **)[undos itemAtIndex:i]; t += undo->xs * undo->ys * sizeof(sqr); if (t > maxremain) { OFFreeMemory(undo); [undos removeItemAtIndex:i]; } } } void makeundo() { if (undos == nil) undos = [[OFMutableData alloc] initWithItemSize:sizeof(block *)]; block *copy = blockcopy(sel); [undos addItem:©]; pruneundos(undomegs << 20); } void editundo() { EDITMP; if (undos.count == 0) { conoutf(@"nothing more to undo"); return; } block *p = *(block **)undos.lastItem; [undos removeLastItem]; blockpaste(*p); OFFreeMemory(p); } block *copybuf = NULL; void |
︙ | ︙ |