[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]

There are two different API implementation to get data.

  // (*1) return, length of data remained.
  get_data(char* buffer /*in/out*/, int buffer_size/*in*/);

  // (*2) caller should free memory of (*data).
  get_data(char** data/*out*/, int* len/*out*/);

(*1) :
  This is very clear and safe, but inefficient in performance point of view and difficult to implement.
  And, the one who allocates memory, frees it too. (very reasonable. So, there is less risk of memory leak.)
(*2) : contrary to (*1)

Which one is better? In general, (*1) is recommended.

In terms of memory allocation/free, if possible, the one who allocates should free it. In case of this is not reasonable, at least, allocation-free-pair should be easy to track!

+ Recent posts