Mercurial > octave-nkf
comparison liboctave/oct-sort.cc @ 5760:8d7162924bd3
[project @ 2006-04-14 04:01:37 by jwe]
author | jwe |
---|---|
date | Fri, 14 Apr 2006 04:01:40 +0000 |
parents | 4c8a2e4e0717 |
children | 1de9a198a303 |
comparison
equal
deleted
inserted
replaced
5759:ce79d238f142 | 5760:8d7162924bd3 |
---|---|
435 | 435 |
436 static inline int | 436 static inline int |
437 roundupsize(int n) | 437 roundupsize(int n) |
438 { | 438 { |
439 unsigned int nbits = 3; | 439 unsigned int nbits = 3; |
440 unsigned int n2 = (unsigned int)n >> 8; | 440 unsigned int n2 = static_cast<unsigned int> (n) >> 8; |
441 | 441 |
442 /* Round up: | 442 /* Round up: |
443 * If n < 256, to a multiple of 8. | 443 * If n < 256, to a multiple of 8. |
444 * If n < 2048, to a multiple of 64. | 444 * If n < 2048, to a multiple of 64. |
445 * If n < 16384, to a multiple of 512. | 445 * If n < 16384, to a multiple of 512. |
481 need = roundupsize(need); | 481 need = roundupsize(need); |
482 /* Don't realloc! That can cost cycles to copy the old data, but | 482 /* Don't realloc! That can cost cycles to copy the old data, but |
483 * we don't care what's in the block. | 483 * we don't care what's in the block. |
484 */ | 484 */ |
485 merge_freemem( ); | 485 merge_freemem( ); |
486 ms.a = (T *) malloc (need * sizeof (T)); | 486 ms.a = static_cast <T *> (malloc (need * sizeof (T))); |
487 if (ms.a) { | 487 if (ms.a) { |
488 ms.alloced = need; | 488 ms.alloced = need; |
489 return 0; | 489 return 0; |
490 } | 490 } |
491 merge_freemem( ); /* reset to sane state */ | 491 merge_freemem( ); /* reset to sane state */ |