mailing list of musl libc
 help / color / mirror / code / Atom feed
* crypt_data: structure size in crypt.c vs. crypt.h
@ 2013-04-11 22:42 Zvi Gilboa
  2013-04-11 22:59 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Zvi Gilboa @ 2013-04-11 22:42 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 840 bytes --]

Greetings,

Looking at crypt.c and crypt.h, I was wondering whether having 
different-size /crypt_data/ structures was intentional, and if so, for 
what reason.  At the moment, the declarations are (and see also the 
attached code):

/<crypt.h>/
struct crypt_data {
     int initialized;
     char *__buf[256]*;
}; /* 260 bytes when sizeof(int)==4 */

/<crypt.c>/
char *__crypt_r(const char *, const char *, *struct crypt_data **);

char *crypt(const char *key, const char *salt)
{
     static char *buf[128]*;
     return __crypt_r(key, salt, *(struct crypt_data *)buf*);
     /* when sizeof(int)==4, this leaves __buf with 124 bytes. */
}


On that note: since the /initialized /member is (currently) never 
referenced by name, adding a comment about that to the code might help 
readers who are yet to be initiated:)

Best regards,
Zvi


[-- Attachment #1.2: Type: text/html, Size: 1359 bytes --]

[-- Attachment #2: crypt_data_struct_size.c --]
[-- Type: text/x-csrc, Size: 264 bytes --]

#include <stdio.h>
#include <crypt.h>

int main(void) {
	struct crypt_data cd;
	static char buf[128];
	
	printf("sizeof(int)\t\t\t%zu\n", sizeof(int));
	printf("sizeof(crypt_data)\t\t%zu\n", sizeof(cd));
	printf("sizeof(static char[128])\t%zu\n", sizeof(buf));
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-12  2:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 22:42 crypt_data: structure size in crypt.c vs. crypt.h Zvi Gilboa
2013-04-11 22:59 ` Rich Felker
2013-04-12  0:03   ` Zvi Gilboa
2013-04-12  1:42     ` Rich Felker
2013-04-12  2:18       ` Zvi Gilboa

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).