Тег c

bitfield
    unsigned long  f_bsize;    /* file system block size */
    unsigned long  f_frsize;   /* fragment size */
    fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */

Линус, ты пьян, иди домой.

RA

Нужна помощь знающих людей по си. Есть php расширение
https://github.com/Rabotyah.../php7/array_to_dom.c
оно преобразует массив в dom-документ. Но иногда вылетает "recursion detected", см строку 196. И я не знаю почему это могло бы происходить.
Тут может ещё скил в php расширениях нужен.

112
TValue*rb=((((((int)(((i)>>(((0+6)+8)+9))&((~((~(Instruction)0)<<9))<<0)))))&(1<<(9-1)))?k+((int)((((int)(((i)>>(((0+6)+8)+9))&((~((~(Instruction)0)<<9))<<0)))))&~(1<<(9-1))):base+(((int)(((i)>>(((0+6)+8)+9))&((~((~(Instruction)0)<<9))<<0)))));
TValue*rc=((((((int)(((i)>>((0+6)+8))&((~((~(Instruction)0)<<9))<<0)))))&(1<<(9-1)))?k+((int)((((int)(((i)>>((0+6)+8))&((~((~(Instruction)0)<<9))<<0)))))&~(1<<(9-1))):base+(((int)(((i)>>((0+6)+8))&((~((~(Instruction)0)<<9))<<0)))));
{L->savedpc=pc;{if((((rb)->tt)==((rc)->tt)&&luaV_equalval(L,rb,rc))==(((int)(((i)>>(0+6))&((~((~(Instruction)0)<<8))<<0))))) {(pc)+=(((((int)(((*pc)>>((0+6)+8))&((~((~(Instruction)0)<<(9+9)))<<0))))-(((1<<(9+9))-1)>>1)));};;};base=L->base;}

но хаскель трудночитаемый и сложный

bitfield

Нашли прекрасную багу у сотрудника, который в отпуске.

В заголовочном файле есть константа

#define BUFSIZE 8128

Приходит пакет размером 3 КБ и ... обрабатывается неверно.
Читаем код функции: буфер размером BUFSIZ, в который копируется пакет.
Стоп! Что такое BUFSIZ? Откуда оно берется?
F12 (Go to Definition) и попадаем в stdio.h:

#define BUFSIZ 512

PS. Осталось еще узнать, почему 8128, а не 8*1024=8192.

Tishka17

Вижуал студия 2015 не полностью поддерживает C99. Да они охренели!

bitfield

мимими 1:

The "best" example of this maintainability problem could be found in the old implementation of the printf family of functions. The CRT provides 142 different variations of printf, but most of the behavior is the same for all of the functions, so there are a set of common implementation functions that do the bulk of the work. These common implementation functions were all defined in output.c in the CRT sources(1). This 2,696 line file had 223 conditionally compiled regions of code (#ifdef, #else, etc.), over half of which were in a single 1,400 line function. This file was compiled 12 different ways to generate all of the common implementation functions.

мимими 2:

We have converted most of the CRT sources to compile as C++, enabling us to replace many ugly C idioms with simpler and more advanced C++ constructs. The publicly callable functions are still declared as C functions, of course (extern "C" in C++), so they can still be called from C. But internally we now take full advantage of the C++ language and its many useful features.

мимими 3:

Before this refactoring, the sprintf functions, which write formatted data to a character buffer, were implemented by wrapping the result buffer in a temporary FILE object and then deferring to the equivalent fprintf function.

112

C/invoke Даже удобнее чем libffi. Няшная штука.

RA

Вот расширение и готово. https://github.com/Rabotyahoff/array_to_dom Сделано на основе вот этого https://github.com/DmitryKoterov/dom_varimport
Нужно оно для того чтобы перегонять массив в domDocument. Но в оригинальном расширении структура входящего массива совсем не та, которую использую я.
Раньше эта задача выполнялась средствами php, но было медленным #aaet.

Теперь мой тест выглядит так
arrayToXML
0.2050
0.2020
0.2027

arrayToDOM
0.0619
0.0656
0.0659

array_to_dom
0.0095
0.0124
0.0134

Последний тест говорит, что преобразование через расширение чуть ли не в 20 раз быстрее преобразования в текстовый xml и в 6 раз быстрее преобразования в domDocument средствами php.

PS Расширение работает несмотря на скепсис #acip/37

RA

Подскажите нубу как узнать код написан на c или на c++?

Добавить пост

Вы можете выбрать до 10 файлов общим размером не более 10 МБ.
Для форматирования текста используется Markdown.