nanogui: Thread: [patch] added const qualifier in nano-X API


[<<] [<] Page 1 of 1 [>] [>>]
Subject: [patch] added const qualifier in nano-X API
From: "Alexander Stohr" ####@####.####
Date: 29 Jun 2005 16:15:54 +0100
Message-Id: <000001c57cbd$57184a40$9b01a8c0@starlightpc>

Hello,

as i tried the below a few times:

  #define TEXT "hello world"
    GrGCGetTextSize (gc, TEXT, strlen (TEXT), 0, &w, &h, &base);
    GrText (draw_id, gc, x, y, TEXT, strlen (TEXT), 0);

and got complaints about TEXT beeing a const pointer
whilst the function expects a pointer to modifiable data.
so i went into the deep of nano-X for checking
why nano-X "wants to modify" the user provided strings.

the result that far is:
nano-X does not want to modify the pointer provided data.

the attached patch now does add the const qualifier
in a significant amount of places in the nano-X API
thus allowing the user to pass constant strings and
compareable buffers to the grafics system. it further
makes sure that nano-X allocates its very own buffers
in cases where it previousely altered user supplied
data. this is especially helpfull against runtime
errors and faults if the user data was located in
a ROM area or in a read-only data segment.

((
for those who really still want nano-X behaving unclean
(but maybe it will be much faster or much smaller in code
- and i doubt both, even if its a true server design)
i left in a local define that allows customisation,
but its really not recommended to enable that switch.
))

i must admit that i am not in state to check against 
any possible compilation option and target, so this
patch might still have some holes concerning other archs
but those holes should be relatively simple to resolve.
for platforms where never ever anyone complains there
should be anyways no urgent need for getting this resolved.

-Alex.

[Content type application/octet-stream not shown. Download]
Subject: Re: [nanogui] [patch] added const qualifier in nano-X API
From: "Greg Haerr" ####@####.####
Date: 9 Jul 2005 15:36:40 +0100
Message-Id: <4c3801c58493$7b598350$6401a8c0@winXP>

: the attached patch now does add the const qualifier
: in a significant amount of places in the nano-X API
: thus allowing the user to pass constant strings and
: compareable buffers to the grafics system. it further
: makes sure that nano-X allocates its very own buffers
: in cases where it previousely altered user supplied
: data. this is especially helpfull against runtime
: errors and faults if the user data was located in
: a ROM area or in a read-only data segment.

Thanks for the patch, I'll take a close look at it. 
Initially, I went the easy route and didn't code const
declarations throughout the API, but have been
leaning towards this more complex and precise
approach.  Provided that this doesn't cause too
much upset with existing programs and internal
files, we should add this patch.

Regards,

Greg
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.