Subclassing String in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robin Becker

    Subclassing String in C

    A client program wants to pass my code truetype font files which have
    already been loaded in memory. Our existing Python/c code reads ttf
    files into memory as strings. I can easily do the same providing the
    client knows the data length.

    I would like to avoid the memory overhead of n+1 bytes which that would
    involve by making a kind of readonly string that refers directly to the
    client memory.

    I can think of two possible approaches 1) implement a buffer compatible
    type from scratch 2) co-opt PyString_Type to subclass String and
    implement a special version of PyString_FromSt ringAndSize that doesn't
    copy and ensure that deallocation is handled properly.

    Any body already invented this kind of wheel? Are there obvious pitfalls
    (other than dangling reference issues etc)?
    --
    Robin Becker
Working...