Add strdup function for ResourceArea

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 25
    • Affects Version/s: None
    • Component/s: hotspot
    • b24

      (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());

            Assignee:
            Anton Artemov
            Reporter:
            Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: