const declarations

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

const declarations

Post by Shine »

Some sce*-functions don't change the data, which are passed as pointers, like

int sceKernelUtilsMd5Digest(u8 *data, u32 size, u8 *digest);

so it should be

int sceKernelUtilsMd5Digest(const u8 *data, u32 size, u8 *digest);

The reason is that when I'm using 3'rd party libraries, sometimes the return values are const, which is fine, but then I have to cast it for the sce*-functions, which is not necessary. I don't think that the changes breaks code, but it makes new code more safe and readable.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

And what's up with "u8 *"? It should be "void *". This isn't the K&R days :).
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

mrbrown wrote:And what's up with "u8 *"? It should be "void *". This isn't the K&R days :).
Yes, this would be fine, too.
Post Reply