From: Ben Pfaff Date: Wed, 13 Apr 2011 03:42:47 +0000 (-0700) Subject: intern: Use UP_CAST macro instad of open-coding it. X-Git-Tag: v0.7.8~67 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=993af59a283dbad8b26a390535f76cdeb00a9108;p=pspp-builds.git intern: Use UP_CAST macro instad of open-coding it. --- diff --git a/src/libpspp/intern.c b/src/libpspp/intern.c index 0bb9277d..258e2829 100644 --- a/src/libpspp/intern.c +++ b/src/libpspp/intern.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include "libpspp/assertion.h" +#include "libpspp/cast.h" #include "libpspp/hash-functions.h" #include "libpspp/hmap.h" @@ -76,8 +77,7 @@ intern_new (const char *s) static struct interned_string * interned_string_from_string (const char *s) { - const size_t ofs = offsetof (struct interned_string, string); - struct interned_string *is = (struct interned_string *) (s - ofs); + struct interned_string *is = UP_CAST (s, struct interned_string, string); assert (is->ref_cnt > 0); return is; }