Subclassing String in C

R

Robin Becker

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_FromStringAndSize 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)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top