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

Function fxPushState

xs/sources/xsre.c:2716–2743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2714}
2715
2716txStateData* fxPushState(txMachine* the, txStateData* firstState, txInteger step, txInteger offset, txUnsigned flags, txCaptureData* captures, txInteger captureCount)
2717{
2718 txInteger size = sizeof(txStateData) + ((captureCount - 1) * sizeof(txCaptureData));
2719 txStateData* state = C_NULL;
2720 if (the && ((firstState == C_NULL) || (firstState->the != C_NULL))) {
2721 txByte* current = (txByte*)firstState;
2722 if (current)
2723 current += size;
2724 else
2725 current = (txByte*)(the->stackBottom);
2726 if ((current + size) < (txByte*)(the->stack)) {
2727 state = (txStateData*)current;
2728 state->the = the;
2729 }
2730 }
2731 if (!state) {
2732 state = c_malloc(size);
2733 if (!state)
2734 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
2735 state->the = C_NULL;
2736 }
2737 state->nextState = firstState;
2738 state->step = step;
2739 state->offset = offset;
2740 state->flags = flags;
2741 c_memcpy(state->captures, captures, captureCount * sizeof(txCaptureData));
2742 return state;
2743}
2744
2745#if defined(__GNUC__)
2746 #define mxBreak continue

Callers 1

fxMatchRegExpFunction · 0.85

Calls 1

fxAbortFunction · 0.70

Tested by

no test coverage detected