예제 #1
0
파일: cstring.py 프로젝트: bramirex/ert
def cstringObj(c_ptr):
    """The cstringObj function is a convenience function which creates a
    Python string copy, and discards the underlying C allocated storage
    for strings created with *alloc() functions in C.

    This function should not be invoked directly, only indirectly
    through the prototyping of the symbol 'cstring_obj'.

    """
    if c_ptr is not None:
        python_string = ctypes.c_char_p( c_ptr ).value
        UTIL_LIB.free( c_ptr )
        return python_string
    else:
        return None
예제 #2
0
파일: cstring.py 프로젝트: bramirex/ert
def cstringObj(c_ptr):
    """The cstringObj function is a convenience function which creates a
    Python string copy, and discards the underlying C allocated storage
    for strings created with *alloc() functions in C.

    This function should not be invoked directly, only indirectly
    through the prototyping of the symbol 'cstring_obj'.

    """
    if c_ptr is not None:
        python_string = ctypes.c_char_p(c_ptr).value
        UTIL_LIB.free(c_ptr)
        return python_string
    else:
        return None