lwqq icon indicating copy to clipboard operation
lwqq copied to clipboard

code style problem

Open microcai opened this issue 13 years ago • 5 comments

There is a lot malloc/free . very bad code style

and use busy loop to waiting for messages ( I'm not refer to the pull form TX server, but the pthread that check for the message queue. )

bad code style

lot of void* , bad code style

:(

hope you guys will improve

microcai avatar Jan 06 '13 14:01 microcai

it 's c ; not java ; no gc

i'm also considered this question.

infact i didn't know there is a better way to implement.

if you know. please teach me.

2013/1/6 microcai [email protected]

There is a lot malloc/free . very bad code style

and use busy loop to waiting for messages ( I'm not refer to the pull form TX server, but the pthread that check for the message queue. )

bad code style

lot of void* , bad code style

:(

hope you guys will improve

— Reply to this email directly or view it on GitHubhttps://github.com/mathslinux/lwqq/issues/19.

xiehuc avatar Jan 07 '13 01:01 xiehuc

Hi, Since we developed it with C, so malloc()/free() were unavoidable, but I have wraped them as s_malloc()/s_free(). Maybe for later development, we can implement a memory pool by reworking s_malloc()/s_free() with caller remaining unchanged.

For busy loop designed for receiving messages, I must admit that there are little suck for this design. So, if you have any better suggestion, patches are welcome!

mathslinux avatar Jan 07 '13 02:01 mathslinux

I have an libwebqq implemented inside qqbot (https://github.com/microcai/qqbot )

Just one thread, no busy loop. two polling connection. every thing is done async.

must of the code is copy&paste from lwqq .

microcai avatar Jan 07 '13 09:01 microcai

good job

2013/1/7 microcai [email protected]

I have an libwebqq implemented inside qqbot ( https://github.com/microcai/qqbot )

Just one thread, no busy loop. two polling connection. every thing is done async.

must of the code is copy&paste from lwqq .

— Reply to this email directly or view it on GitHubhttps://github.com/mathslinux/lwqq/issues/19#issuecomment-11944677.

xiehuc avatar Jan 07 '13 09:01 xiehuc

If you develop in C, the trick is to use glib. glib provide g_new/g_free , and for async loop, you have g_main_loop pruple have pruple loop wrapper arround g_main_loop , you can use neither glib nor pruple.

microcai avatar Jan 09 '13 01:01 microcai