From e947f535f3afdd28107ed4e8f62008ba123d9628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Mon, 22 Sep 2014 16:57:31 +0800 Subject: [PATCH] bug fix --- TinySTL/Alloc.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TinySTL/Alloc.h b/TinySTL/Alloc.h index 2a4a43c..9da069c 100644 --- a/TinySTL/Alloc.h +++ b/TinySTL/Alloc.h @@ -71,11 +71,12 @@ namespace TinySTL{ void alloc::deallocate(void *ptr, size_t bytes){ if (bytes > EMaxBytes::MAXBYTES){ free(ptr); + }else{ + size_t index = FREELIST_INDEX(bytes); + obj *node = static_cast(ptr); + node->next = free_list[index]; + free_list[index] = node; } - size_t index = FREELIST_INDEX(bytes); - obj *node = static_cast(ptr); - node->next = free_list[index]; - free_list[index] = node; } void *alloc::reallocate(void *ptr, size_t old_sz, size_t new_sz){ deallocate(ptr, old_sz);