• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

12.4.4.2 Reading data from a term
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Analysing Terms via the Foreign Interface
            • Reading data from a term
              • PL_get_atom()
              • PL_get_atom_chars()
              • PL_get_string_chars()
              • PL_get_chars()
              • PL_get_list_chars()
              • PL_get_integer()
              • PL_get_long()
              • PL_get_int64()
              • PL_get_uint64()
              • PL_get_intptr()
              • PL_get_bool()
              • PL_get_stdbool()
              • PL_get_pointer()
              • PL_get_float()
              • PL_get_functor()
              • PL_get_name_arity()
              • PL_get_compound_name_arity()
              • PL_get_module()
              • PL_get_arg()
              • PL_get_arg_values()
              • PL_get_dict_key()
    • Packages
Availability:C-language interface function
bool PL_get_pointer(term_t +t, void **ptr)
Together with PL_put_pointer() and PL_unify_pointer(), these functions allow representing a C pointer as a Prolog integer. PL_put_pointer() and PL_unify_pointer() create a pointer integer: an integer that behaves as any other integer, but is a different term than the plain integer with the same value: the two do not unify and compare/3 orders the pointer integer directly after the plain integer. Pointer integers survive assert/1, recorded databases, findall/3, copy_term/2, tries and tables. They become plain integers if they are written and read, serialized with fast_term_serialized/2 or PL_record_external(), saved in a .qlf file or used in arithmetic. PL_get_pointer() only succeeds on a pointer integer, so a plain integer typed by the user or computed using arithmetic is not taken for a pointer. A pointer must fit in a small integer (max_tagged_integer); otherwise PL_put_pointer() and PL_unify_pointer() raise a representation error. The exception is 64-bit Android, which keeps a tag in the top byte of heap pointers: there such pointers are represented as plain integers and PL_get_pointer() accepts integers that are too large to be small. Representing C pointers as integers is unsafe: the pointer may be used after the object it points at is deallocated. The blob API described in section 12.4.10 provides a safe way for handling foreign resources that cooperates with Prolog garbage collection.
ClioPatria (version V3.1.1-59-g7b9a7a3)