F
Fr?d?ric Ledain
Hi.
I have to design new API, which some of them have to return a string.
I have mixed feelings about the various strategies I can choose :
1. API(char *s, long *size)
=> the client gives a string pointer and its size; If the server has
to return a longer string, it fails, and the client calls back with a
longer string.
2. API(char *s)
=> the client receives a statically allocated string pointer from the
server. It can be changed when the client calls other APIs.
3. API(char *s)
=> the client receives a dynamically allocated copy of the string from
the server. The client has to call back the server to release this
pointer (APIRelease(s));
Can you help me to choose the "best" one ?
My constraints : multi-thread, Windows / UNIX.
Thanks a lot in advance.
Fred
I have to design new API, which some of them have to return a string.
I have mixed feelings about the various strategies I can choose :
1. API(char *s, long *size)
=> the client gives a string pointer and its size; If the server has
to return a longer string, it fails, and the client calls back with a
longer string.
2. API(char *s)
=> the client receives a statically allocated string pointer from the
server. It can be changed when the client calls other APIs.
3. API(char *s)
=> the client receives a dynamically allocated copy of the string from
the server. The client has to call back the server to release this
pointer (APIRelease(s));
Can you help me to choose the "best" one ?
My constraints : multi-thread, Windows / UNIX.
Thanks a lot in advance.
Fred