Revision a17b2fd3
b/arch_init.c | ||
---|---|---|
664 | 664 |
DPRINTF("Error creating cache\n"); |
665 | 665 |
return -1; |
666 | 666 |
} |
667 |
XBZRLE.encoded_buf = g_malloc0(TARGET_PAGE_SIZE); |
|
668 |
XBZRLE.current_buf = g_malloc(TARGET_PAGE_SIZE); |
|
667 |
|
|
668 |
/* We prefer not to abort if there is no memory */ |
|
669 |
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE); |
|
670 |
if (!XBZRLE.encoded_buf) { |
|
671 |
DPRINTF("Error allocating encoded_buf\n"); |
|
672 |
return -1; |
|
673 |
} |
|
674 |
|
|
675 |
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE); |
|
676 |
if (!XBZRLE.current_buf) { |
|
677 |
DPRINTF("Error allocating current_buf\n"); |
|
678 |
g_free(XBZRLE.encoded_buf); |
|
679 |
XBZRLE.encoded_buf = NULL; |
|
680 |
return -1; |
|
681 |
} |
|
682 |
|
|
669 | 683 |
acct_clear(); |
670 | 684 |
} |
671 | 685 |
|
b/page_cache.c | ||
---|---|---|
60 | 60 |
return NULL; |
61 | 61 |
} |
62 | 62 |
|
63 |
cache = g_malloc(sizeof(*cache)); |
|
64 |
|
|
63 |
/* We prefer not to abort if there is no memory */ |
|
64 |
cache = g_try_malloc(sizeof(*cache)); |
|
65 |
if (!cache) { |
|
66 |
DPRINTF("Failed to allocate cache\n"); |
|
67 |
return NULL; |
|
68 |
} |
|
65 | 69 |
/* round down to the nearest power of 2 */ |
66 | 70 |
if (!is_power_of_2(num_pages)) { |
67 | 71 |
num_pages = pow2floor(num_pages); |
... | ... | |
74 | 78 |
|
75 | 79 |
DPRINTF("Setting cache buckets to %" PRId64 "\n", cache->max_num_items); |
76 | 80 |
|
77 |
cache->page_cache = g_malloc((cache->max_num_items) * |
|
78 |
sizeof(*cache->page_cache)); |
|
81 |
/* We prefer not to abort if there is no memory */ |
|
82 |
cache->page_cache = g_try_malloc((cache->max_num_items) * |
|
83 |
sizeof(*cache->page_cache)); |
|
84 |
if (!cache->page_cache) { |
|
85 |
DPRINTF("Failed to allocate cache->page_cache\n"); |
|
86 |
g_free(cache); |
|
87 |
return NULL; |
|
88 |
} |
|
79 | 89 |
|
80 | 90 |
for (i = 0; i < cache->max_num_items; i++) { |
81 | 91 |
cache->page_cache[i].it_data = NULL; |
Also available in: Unified diff