From: EvilPudding Date: Wed, 13 Apr 2016 15:53:15 +0000 (+0000) Subject: Hex in struct Colorpixel.hex to contiguous memory X-Git-Tag: 4.13~54^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=08c23805458c6bf663aabf76cc667db84ad4b8a9;p=i3%2Fi3 Hex in struct Colorpixel.hex to contiguous memory No reason for hex not to be of a constant size, and no reason to introduce a cache miss by allocating it separated from the rest of the structure. --- diff --git a/libi3/get_colorpixel.c b/libi3/get_colorpixel.c index a0a9e345..218f82e6 100644 --- a/libi3/get_colorpixel.c +++ b/libi3/get_colorpixel.c @@ -13,7 +13,7 @@ #include "libi3.h" struct Colorpixel { - char *hex; + char hex[8]; uint32_t pixel; SLIST_ENTRY(Colorpixel) @@ -74,7 +74,7 @@ uint32_t get_colorpixel(const char *hex) { /* Store the result in the cache */ struct Colorpixel *cache_pixel = scalloc(1, sizeof(struct Colorpixel)); - cache_pixel->hex = sstrdup(hex); + strncpy(cache_pixel->hex, hex, 8); cache_pixel->pixel = pixel; SLIST_INSERT_HEAD(&(colorpixels), cache_pixel, colorpixels);