summaryrefslogtreecommitdiff
path: root/epan/emem.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2007-01-15 05:16:13 +0000
committerUlf Lamping <ulf.lamping@web.de>2007-01-15 05:16:13 +0000
commite3330fd9229c9b1dee36075ed260f6ded08af3b1 (patch)
tree65a493d1fa5798cb206fb7edb6ef6cdf72973b05 /epan/emem.c
parente31d777279d28800e520549fd8ad4c7f2d4b089e (diff)
downloadwireshark-e3330fd9229c9b1dee36075ed260f6ded08af3b1.tar.gz
instead of simply doing an assert when running out of memory in emem, throw a new OutOfMemoryError Exception, so file.c can show at least a better explanation to the user before Wireshark terminates
XXX - to prevent a busy wait, I need a portable way to wait for a short time period, like Sleep() for Windows svn path=/trunk/; revision=20437
Diffstat (limited to 'epan/emem.c')
-rw-r--r--epan/emem.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/epan/emem.c b/epan/emem.c
index 88945a8387..f4945d8f16 100644
--- a/epan/emem.c
+++ b/epan/emem.c
@@ -288,7 +288,9 @@ emem_create_chunk(emem_chunk_t **free_list) {
/* XXX - is MEM_COMMIT|MEM_RESERVE correct? */
npc->buf = VirtualAlloc(NULL, EMEM_PACKET_CHUNK_SIZE,
MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
- g_assert(npc->buf != NULL);
+ if(npc->buf == NULL) {
+ THROW(OutOfMemoryError);
+ }
buf_end = npc->buf + EMEM_PACKET_CHUNK_SIZE;
/* Align our guard pages on page-sized boundaries */
@@ -308,7 +310,10 @@ emem_create_chunk(emem_chunk_t **free_list) {
#elif defined(USE_GUARD_PAGES)
npc->buf = mmap(NULL, EMEM_PACKET_CHUNK_SIZE,
PROT_READ|PROT_WRITE, ANON_PAGE_MODE, ANON_FD, 0);
- g_assert(npc->buf != MAP_FAILED);
+ if(npc->buf == MAP_FAILED) {
+ /* XXX - what do we have to cleanup here? */
+ THROW(OutOfMemoryError);
+ }
buf_end = npc->buf + EMEM_PACKET_CHUNK_SIZE;
/* Align our guard pages on page-sized boundaries */
@@ -325,11 +330,14 @@ emem_create_chunk(emem_chunk_t **free_list) {
npc->free_offset = npc->free_offset_init;
#else /* Is there a draft in here? */
+ npc->buf = malloc(EMEM_PACKET_CHUNK_SIZE);
+ if(npc->buf == NULL) {
+ THROW(OutOfMemoryError);
+ }
npc->amount_free_init = EMEM_PACKET_CHUNK_SIZE;
npc->amount_free = npc->amount_free_init;
npc->free_offset_init = 0;
npc->free_offset = npc->free_offset_init;
- npc->buf = g_malloc(EMEM_PACKET_CHUNK_SIZE);
#endif /* USE_GUARD_PAGES */
}
}