summaryrefslogtreecommitdiff
path: root/encode.c
diff options
context:
space:
mode:
authorGraham Miller <graham.miller@gmail.com>2011-02-09 18:49:53 -0500
committerGraham Miller <graham.miller@gmail.com>2011-02-09 18:49:53 -0500
commit4e228b5d61e25823b573457b170ad012c86a0a71 (patch)
tree2c5a9da5750b6db4e8dc6dec5c671c8982882482 /encode.c
parentab75d98b84db3583ed51042dcf470d4e1b05d413 (diff)
downloadlibgob-4e228b5d61e25823b573457b170ad012c86a0a71.tar.gz
libgob-4e228b5d61e25823b573457b170ad012c86a0a71.tar.bz2
changed encode_double to use memecpy0.3
Diffstat (limited to 'encode.c')
-rw-r--r--encode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/encode.c b/encode.c
index 687dbfe..acf24b7 100644
--- a/encode.c
+++ b/encode.c
@@ -80,7 +80,11 @@ int gob_encode_boolean(char *buf, size_t buf_size, int b) {
}
int gob_encode_double(char *buf, size_t buf_size, double d) {
- return gob_encode_unsigned_long_long(buf, buf_size, flip_unsigned_long_long(*(unsigned long long*)&d));
+ unsigned long long ull = 0;
+ memcpy((char*)&ull, &d, sizeof(double));
+ unsigned long long rev_ull = flip_unsigned_long_long(ull);
+
+ return gob_encode_unsigned_long_long(buf, buf_size, rev_ull);
}
int gob_encode_string(char *buf, size_t buf_size, const char *s) {