#NEWLINE# def check_string( result , func , cargs , offset = ( - 1 ) , str_result = False ) : #NEWLINE# #INDENT# '\n    Checks the string output returned from the given function, and frees\n    the string pointer allocated by OGR.  The `str_result` keyword\n    may be used when the result is the string pointer, otherwise\n    the OGR error code is assumed.  The `offset` keyword may be used\n    to extract the string pointer passed in by-reference at the given\n    slice offset in the function arguments.\n    ' #NEWLINE# if str_result : #NEWLINE# #INDENT# ptr = result #NEWLINE# if ( not ptr ) : #NEWLINE# #INDENT# s = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# s = string_at ( result ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# check_err ( result ) #NEWLINE# ptr = ptr_byref ( cargs , offset ) #NEWLINE# s = ptr . value #NEWLINE# #UNINDENT# if ptr : #NEWLINE# #INDENT# lgdal . VSIFree ( ptr ) #NEWLINE# #UNINDENT# return s