Talk:Sokoban: Difference between revisions
Content added Content deleted
(→C++ Version: small note about C standards) |
(+ notes on long C version) |
||
Line 20: | Line 20: | ||
::: I don't know how or if you can change your login name. [[User:Short Circuit]] is the man to ask; you can also try the IRC. --[[User:Ledrug|Ledrug]] 21:29, 4 May 2012 (UTC) |
::: I don't know how or if you can change your login name. [[User:Short Circuit]] is the man to ask; you can also try the IRC. --[[User:Ledrug|Ledrug]] 21:29, 4 May 2012 (UTC) |
||
::: About C89/99: I tend to follow the older standard here, since C89 is supposed to be more portable across compilers. Whether the C89 ''I'' write is portable is a completely separate issue. --[[User:Ledrug|Ledrug]] 21:40, 4 May 2012 (UTC) |
::: About C89/99: I tend to follow the older standard here, since C89 is supposed to be more portable across compilers. Whether the C89 ''I'' write is portable is a completely separate issue. --[[User:Ledrug|Ledrug]] 21:40, 4 May 2012 (UTC) |
||
==The Long C Version== |
|||
1) It's often bad to put code with side effects inside assert(). Lines of code like this are a bug, because with <code>#define NDEBUG</code> the allocation doesn't happen: |
|||
<lang c>assert( board = calloc(w * h, sizeof(uint8_t)) );</lang> |
|||
2) In some declarations "s" could be declared as pointing to const: <lang c>inline int deadlocked(state_t *s) |
|||
void unqueue_move(state_t *s)</lang> |