Quantcast
Channel: Adobe Community: Message List - Acrobat SDK
Viewing all articles
Browse latest Browse all 10848

Re: Pdf Color Conversion (to RGB)

$
0
0

A diversion: why do some structures (in the Acrobat API and elsewhere) have lengths? It is to support binary compatibility.

 

Let's imagine a structure in version 3 of a product which looks like this

 

struct { int structuresize ;

int actioncode } ;

 

then in version 4 it looks like this

struct { int structuresize ;

int actioncode ;

char *caption /* a string or NULL */ } ;

 

And let's imagine the code zeroes the structure. Using the version 4 headers, caption will then be NULL and all is well. But if the version 3 headers are used caption doen't exist. It isn't zeroed, and the value is whatever happens to be in the memory following the structure. It might sometimes be zero, and all is well. Then one day it isn't zero: the program crashes or worse.

 

Thanks to the length this won't happen. The API checks the length of the structure to see if it is long enough to hold caption. If not, a default is used. No crashes, no need to recompile; everyone is happy.


Viewing all articles
Browse latest Browse all 10848

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>