Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8354969

Add strdup function for ResourceArea

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • hotspot

      (Maybe for Arena as well)

      Sometimes we need to duplicate a string on the resource:

          ResourceArea rm;
          const char* s = complex_operation();
          const char* mycopy = strcpy(ResourceArea::allocate(strlen(s)+1), s);

      This often happens when the lifecycle of s is not controlled by the caller (e.g., it could be deallocated outside of the caller control), so we make a resource copy and hold on to it as long as we need it.

      For simplification, we should have something like this:

          ResourceArea rm;
          const char* mycopy = ResourceArea::strdup(complex_operation());

            aartemov Anton Artemov
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: