Changeset 150 for trunk/lib/void_stack.c


Ignore:
Timestamp:
03/01/09 21:17:46 (15 years ago)
Author:
tim
Message:

integrated talloc into most of the rest of the regfi library
fixed a length validation issue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/void_stack.c

    r147 r150  
    44 * leaks.
    55 *
    6  * Copyright (C) 2005,2007 Timothy D. Morgan
     6 * Copyright (C) 2005,2007,2009 Timothy D. Morgan
    77 *
    88 * This program is free software; you can redistribute it and/or modify
     
    2626void_stack* void_stack_new(unsigned short max_size)
    2727{
    28   void_stack* ret_val = (void_stack*)malloc(sizeof(void_stack));
     28  void_stack* ret_val = talloc(NULL, void_stack);
    2929
    3030  if (ret_val != NULL)
    3131  {
    3232    memset(ret_val, 0, sizeof(*ret_val));
    33     ret_val->elements = (void**)malloc(max_size*sizeof(void*));
     33    ret_val->elements = talloc_array(ret_val, void*, max_size);
    3434    if (ret_val->elements == NULL)
    3535    {
    36       free(ret_val);
     36      talloc_free(ret_val);
    3737      ret_val = NULL;
    3838    }
     
    9090void void_stack_free(void_stack* stack)
    9191{
    92   free(stack->elements);
    93   free(stack);
     92  talloc_free(stack);
    9493}
    9594
     
    10099  for(i=0; i < stack->top; i++)
    101100    free(stack->elements[i]);
    102   free(stack->elements);
    103   free(stack);
     101  talloc_free(stack);
    104102}
    105103
     
    154152  if(stack != NULL)
    155153  {
    156     ret_val = (void_stack_iterator*)malloc(sizeof(void_stack_iterator));
     154    ret_val = talloc(stack, void_stack_iterator);
    157155    if (ret_val != NULL)
    158156    {
     
    168166void void_stack_iterator_free(void_stack_iterator* iter)
    169167{
    170   free(iter);
     168  talloc_free(iter);
    171169}
    172170
Note: See TracChangeset for help on using the changeset viewer.