login about faq

Why does

const char *CkHttp_quickGetStr(HCkHttp cHandle, const char *url);

returns a const char and not a char ? And why can I still modify the return value if it's a const?

How does the CkHttp_quickGetStr handle internally the result from the HTTP request? Does it dynamically allocate memory for the response and it gets deallocated by calling CkHttp_Dispose(...)?

asked Oct 23 '15 at 11:01

malin's gravatar image


I assume this is for "C" programming?

Any method that returns a string has 2 forms. The lowercase form returns a "const char *" to internal memory. The uppercase form deposits the string in the CkString object that is passed in the last argument.

For example:

BOOL CkHttp_QuickGetStr(HCkHttp cHandle, const char *url, HCkString outStr);

const char CkHttp_quickGetStr(HCkHttp cHandle, const char url);

The uppercase form might be used like this:

HCkString strObj;
HCkHttp http;
BOOL success;
const char *html;

strObj = CkString_Create(); http = CkHttp_Create(); success = CkHttp_quickGetStr(http,"https://www.paypal.com/",strObj); html = CkString_getStringUtf8(strObj);


CkHttp_Dispose(http); CkString_Dispose(strObj);

If using the lowercase form, then be sure to use the string pointed to by the returned "const char *" before the CkHttp object is disposed, and before calling other methods. (Actually, you can call up to 10 methods before the least recent "const char *" is recycled.) If your app needs to keep a copy of the string, it should strcpy it to somewhere else. (or you can use the uppercase version of the method and just keep the strObj around..)


answered Oct 23 '15 at 11:45

chilkat's gravatar image

chilkat ♦♦

edited Oct 23 '15 at 11:46

Thank you for your quick response! :-)

(Oct 23 '15 at 11:49) malin
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Oct 23 '15 at 11:01

Seen: 620 times

Last updated: Oct 23 '15 at 11:49

powered by OSQA