MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxNewParserChunk

Function fxNewParserChunk

xs/sources/xsScript.c:174–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172#define kParserChunkSize (4096)
173
174void* fxNewParserChunk(txParser* parser, txSize size)
175{
176 size = (size + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
177 if (size <= parser->chunkSize) {
178 void *result = parser->chunk;
179 parser->chunk += size;
180 parser->chunkSize -= size;
181 return result;
182 }
183
184 if (size > (txSize)(kParserChunkSize - sizeof(txParserChunk))) {
185 txParserChunk *block = c_malloc(sizeof(txParserChunk) + size);
186 if (!block)
187 fxAbort(parser->console, XS_NOT_ENOUGH_MEMORY_EXIT);
188 parser->total += sizeof(txParserChunk) + size;
189 block->next = parser->first;
190 parser->first = block;
191 return block + 1;
192 }
193
194 txParserChunk *block = c_malloc(kParserChunkSize);
195 if (!block)
196 fxAbort(parser->console, XS_NOT_ENOUGH_MEMORY_EXIT);
197 parser->total += kParserChunkSize;
198 block->next = parser->first;
199 parser->first = block;
200 parser->chunk = (txByte*)(block + 1) + size;
201 parser->chunkSize = kParserChunkSize - sizeof(txParserChunk) - size;
202 return block + 1;
203}
204
205void* fxNewParserChunkClear(txParser* parser, txSize size)
206{

Callers 15

_xsbug_script_Function · 0.85
fxGetNextNumberBFunction · 0.85
fxGetNextNumberEFunction · 0.85
fxGetNextNumberOFunction · 0.85
fxGetNextNumberXFunction · 0.85
fxCombinePathFunction · 0.85
fxInitializeParserFunction · 0.85
fxNewParserChunkClearFunction · 0.85
fxNewParserStringFunction · 0.85
fxNewParserSymbolFunction · 0.85
fxPushBigIntNodeFunction · 0.85
fxPushIntegerNodeFunction · 0.85

Calls 1

fxAbortFunction · 0.70

Tested by

no test coverage detected