update copyright date to 2013
[dpdk.git] / lib / librte_malloc / malloc_elem.c
index 1c90908..919d474 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  * 
- *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -30,7 +30,6 @@
  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * 
- *  version: DPDK.L.1.2.3-3
  */
 #include <stdint.h>
 #include <stddef.h>
@@ -232,7 +231,10 @@ malloc_elem_free(struct malloc_elem *elem)
                elem->state = ELEM_FREE;
                elem->pad = 0;
        }
+       /* decrease heap's count of allocated elements */
+       elem->heap->alloc_count--;
        rte_spinlock_unlock(&(elem->heap->lock));
+
        return 0;
 }
 
@@ -265,7 +267,7 @@ malloc_elem_resize(struct malloc_elem *elem, size_t size)
        if (elem->size - new_size > MIN_DATA_SIZE + MALLOC_ELEM_OVERHEAD){
                /* now we have a big block together. Lets cut it down a bit, by splitting */
                struct malloc_elem *split_pt = RTE_PTR_ADD(elem, new_size);
-               split_pt = RTE_ALIGN_CEIL(split_pt, CACHE_LINE_SIZE);
+               split_pt = RTE_PTR_ALIGN_CEIL(split_pt, CACHE_LINE_SIZE);
                split_elem(elem, split_pt);
                split_pt->state = ELEM_FREE;
                split_pt->next_free = elem->heap->free_head;