- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
switch(argCount)
{
case 0: sprintf(dst, fmt); break;
case 1: sprintf(dst, fmt, args[0]); break;
case 2: sprintf(dst, fmt, args[0], args[1]); break;
case 3: sprintf(dst, fmt, args[0], args[1], args[2]); break;
case 4: sprintf(dst, fmt, args[0], args[1], args[2], args[3]); break;
case 5: sprintf(dst, fmt, args[0], args[1], args[2], args[3], args[4]); break;
case 6: sprintf(dst, fmt, args[0], args[1], args[2], args[3], args[4], args[5]); break;
case 7: sprintf(dst, fmt, args[0], args[1], args[2], args[3], args[4], args[5], args[6]); break;
case 8: sprintf(dst, fmt, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); break;
...
напиши пожалуйста sprintf на асемблере.
или ты просто про вызов готового? тогда простота зависит от колконвеншена
1. Restrict to simple control flow constructs. Do not use goto statements, setjmp, longjmp, or recursion.
2. Give all loops a fixed upper-bound.
3. Do not use dynamic memory allocation after initialization.
4. Limit functions to no more than 60 lines of text.
5. Use minimally 2 assertions for every function of more than 10 lines.
6. Declare data objects at the smallest possible level of scope.
7. Check the return value of all non-void functions, and check the validity of all function parameters.
8. Limit the use of the preprocessor to file inclusion and simple macros.
...
9. Limit the use of pointers. Use no more than 1 level of dereferencing per expression.
10. Compile with all warnings enabled, in pedantic mode, and use one or more modern static source code analyzers.
Ну это хамство. Или я чего-то не понял.
Остальное звучит вполне здраво.
Нямёк на то, что заранее выделенные буфера и пулы всегда работают надёжнее и быстрее, чем динамический аллокатор.
Даже если это и паскаль, то с какими-то флагами.
Fixed.
case 9: sprintf(dst, fmt, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); break;