Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-2407

We should add API TSUrlStringGetBuf in ts.h

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Patch Available
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: sometime
    • Component/s: HTTP

      Description

      the existing API TSUrlStringGet call ats_malloc to malloc buffer for the url string. the caller should call ats_free to free the buffer. the API prototype is:
      tsapi char* TSUrlStringGet(TSMBuffer bufp, TSMLoc offset, int* length);
      call this API is expensive because dynamic memory alloc and free.

      we wish the buffer can be passed in. the new API prototype is:
      tsapi char* TSUrlStringGetBuf(TSMBuffer bufp, TSMLoc offset, char buff, int buf_size, int length);

      the implements as:
      char *
      TSUrlStringGetBuf(TSMBuffer bufp, TSMLoc obj, char buff, int buf_size, int length)
      {
      sdk_assert(sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS);
      sdk_assert(sdk_sanity_check_url_handle(obj) == TS_SUCCESS);
      sdk_assert(sdk_sanity_check_null_ptr((void*)buff) == TS_SUCCESS);
      sdk_assert(sdk_sanity_check_null_ptr((void*)length) == TS_SUCCESS);

      URLImpl *url_impl = (URLImpl *) obj;
      return url_string_get_buf(url_impl, buff, buf_size, length);
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              happy_fish100 Yu Qing
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: