(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());
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());
- links to
-
Review(master) openjdk/jdk/24998