* Re-allocate an allocation that was originally guarded. */
| 415 | * Re-allocate an allocation that was originally guarded. |
| 416 | */ |
| 417 | void * |
| 418 | memguard_realloc(void *addr, unsigned long size, struct malloc_type *mtp, |
| 419 | int flags) |
| 420 | { |
| 421 | void *newaddr; |
| 422 | u_long old_size; |
| 423 | |
| 424 | /* |
| 425 | * Allocate the new block. Force the allocation to be guarded |
| 426 | * as the original may have been guarded through random |
| 427 | * chance, and that should be preserved. |
| 428 | */ |
| 429 | if ((newaddr = memguard_alloc(size, flags)) == NULL) |
| 430 | return (NULL); |
| 431 | |
| 432 | /* Copy over original contents. */ |
| 433 | old_size = *v2sizep(trunc_page((uintptr_t)addr)); |
| 434 | bcopy(addr, newaddr, min(size, old_size)); |
| 435 | memguard_free(addr); |
| 436 | return (newaddr); |
| 437 | } |
| 438 | |
| 439 | static int |
| 440 | memguard_cmp(unsigned long size) |
no test coverage detected