equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
197 return old; |
197 return old; |
198 } |
198 } |
199 } |
199 } |
200 |
200 |
201 // Fast delete in area. Common case is: NOP (except for storage reclaimed) |
201 // Fast delete in area. Common case is: NOP (except for storage reclaimed) |
202 void Afree(void *ptr, size_t size) { |
202 bool Afree(void *ptr, size_t size) { |
203 #ifdef ASSERT |
203 #ifdef ASSERT |
204 if (ZapResourceArea) memset(ptr, badResourceValue, size); // zap freed memory |
204 if (ZapResourceArea) memset(ptr, badResourceValue, size); // zap freed memory |
205 if (UseMallocOnly) return; |
205 if (UseMallocOnly) return true; |
206 #endif |
206 #endif |
207 if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr; |
207 if (((char*)ptr) + size == _hwm) { |
|
208 _hwm = (char*)ptr; |
|
209 return true; |
|
210 } else { |
|
211 // Unable to fast free, so we just drop it. |
|
212 return false; |
|
213 } |
208 } |
214 } |
209 |
215 |
210 void *Arealloc( void *old_ptr, size_t old_size, size_t new_size, |
216 void *Arealloc( void *old_ptr, size_t old_size, size_t new_size, |
211 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); |
217 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); |
212 |
218 |