Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Stats collection broken in tideways_realloc() #99

@NoiseByNorthwest

Description

@NoiseByNorthwest

tideways_realloc() does not correctly collect the allocation stats when wrapping the realloc() function.
It currently assumes that:

  • a new allocation is always done, which is not true.
  • a free (of the old memory) is always done, which is not true. Furthermore realloc can be called with NULL as first argument in order to perform an initial allocation.
  • the total allocated memory is always incremented by the size given as 2nd argument, which is not true.

From the manpage man 3 realloc:

The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged in the range from the start of the region up to the minimum of the
old and new sizes. If the new size is larger than the old size, the added memory will not be initialized. If ptr is NULL, then the call is equivalent to malloc(size), for all values of
size; if size is equal to zero, and ptr is not NULL, then the call is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc(), or
realloc(). If the area pointed to was moved, a free(ptr) is done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions