MCPcopy Index your code
hub / github.com/php/frankenphp / extractZvalValue

Function extractZvalValue

types.go:439–464  ·  view source on GitHub ↗

extractZvalValue returns a pointer to the zval value cast to the expected type

(zval *C.zval, expectedType C.uint8_t)

Source from the content-addressed store, hash-verified

437
438// extractZvalValue returns a pointer to the zval value cast to the expected type
439func extractZvalValue(zval *C.zval, expectedType C.uint8_t) (unsafe.Pointer, error) {
440 if zval == nil {
441 if expectedType == C.IS_NULL {
442 return nil, nil
443 }
444
445 return nil, fmt.Errorf("zval type mismatch: expected %d, got nil", expectedType)
446 }
447
448 if zType := C.zval_get_type(zval); zType != expectedType {
449 return nil, fmt.Errorf("zval type mismatch: expected %d, got %d", expectedType, zType)
450 }
451
452 v := unsafe.Pointer(&zval.value[0])
453
454 switch expectedType {
455 case C.IS_LONG, C.IS_DOUBLE:
456 return v, nil
457 case C.IS_STRING:
458 return unsafe.Pointer(*(**C.zend_string)(v)), nil
459 case C.IS_ARRAY:
460 return unsafe.Pointer(*(**C.zend_array)(v)), nil
461 }
462
463 return nil, fmt.Errorf("unsupported zval type %d", expectedType)
464}
465
466func zendStringRelease(p unsafe.Pointer) {
467 zs := (*C.zend_string)(p)

Callers 1

goValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected