Thread: Realloc with new and delete

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    Realloc with new and delete

    Ok after doing a search it appears there is no direct c++ equivlent to realloc. What I want to know is if it is safe to use realloc with new and delete. The type will be char (I'm just getting a chuck of memory) and constructors/destructors do not need to be invoked.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> What I want to know is if it is safe to use realloc with new and delete.
    The generic awnser is no.
    You can simulate realloc() using new and delete and memcpy(). If you need the efficiency of realloc() then use malloc() and free() for your char array.

    gg

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Kinda thought so.

Popular pages Recent additions subscribe to a feed