diff options
author | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:02 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:02 +0100 |
commit | d67ee86091f9e07f8d85c1fb77c7c58989e676bb (patch) | |
tree | 900f5e62bfd8e8c082be75a94f5348dea819beba /ListItem.c | |
parent | 3cbc50cde37fee19ce98ee8260b0a6095b829c4c (diff) | |
parent | 65357c8c46154de4e4eca14075bfe5523bb5fc14 (diff) | |
download | debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.tar.gz debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.tar.bz2 debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.zip |
Update upstream source from tag 'upstream/3.0.3'
Update to upstream version '3.0.3'
with Debian dir 8a3a733dc80e45b1cde220f88fcfd815869742f0
Diffstat (limited to 'ListItem.c')
-rw-r--r-- | ListItem.c | 58 |
1 files changed, 26 insertions, 32 deletions
@@ -1,19 +1,21 @@ /* htop - ListItem.c (C) 2004-2011 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file +Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "ListItem.h" +#include "config.h" // IWYU pragma: keep -#include "CRT.h" -#include "StringUtils.h" -#include "RichString.h" +#include "ListItem.h" -#include <string.h> #include <assert.h> #include <stdlib.h> +#include <string.h> + +#include "CRT.h" +#include "RichString.h" +#include "XUtils.h" static void ListItem_delete(Object* cast) { @@ -22,32 +24,22 @@ static void ListItem_delete(Object* cast) { free(this); } -static void ListItem_display(Object* cast, RichString* out) { - ListItem* const this = (ListItem*)cast; +static void ListItem_display(const Object* cast, RichString* out) { + const ListItem* const this = (const ListItem*)cast; assert (this != NULL); - /* - int len = strlen(this->value)+1; - char buffer[len+1]; - xSnprintf(buffer, len, "%s", this->value); - */ + if (this->moving) { RichString_write(out, CRT_colors[DEFAULT_COLOR], #ifdef HAVE_LIBNCURSESW - CRT_utf8 ? "↕ " : + CRT_utf8 ? "↕ " : #endif - "+ "); + "+ "); } else { RichString_prune(out); } - RichString_append(out, CRT_colors[DEFAULT_COLOR], this->value/*buffer*/); + RichString_append(out, CRT_colors[DEFAULT_COLOR], this->value); } -ObjectClass ListItem_class = { - .display = ListItem_display, - .delete = ListItem_delete, - .compare = ListItem_compare -}; - ListItem* ListItem_new(const char* value, int key) { ListItem* this = AllocThis(ListItem); this->value = xStrdup(value); @@ -57,20 +49,22 @@ ListItem* ListItem_new(const char* value, int key) { } void ListItem_append(ListItem* this, const char* text) { - int oldLen = strlen(this->value); - int textLen = strlen(text); - int newLen = strlen(this->value) + textLen; + size_t oldLen = strlen(this->value); + size_t textLen = strlen(text); + size_t newLen = oldLen + textLen; this->value = xRealloc(this->value, newLen + 1); memcpy(this->value + oldLen, text, textLen); this->value[newLen] = '\0'; } -const char* ListItem_getRef(ListItem* this) { - return this->value; -} - -long ListItem_compare(const void* cast1, const void* cast2) { - ListItem* obj1 = (ListItem*) cast1; - ListItem* obj2 = (ListItem*) cast2; +static long ListItem_compare(const void* cast1, const void* cast2) { + const ListItem* obj1 = (const ListItem*) cast1; + const ListItem* obj2 = (const ListItem*) cast2; return strcmp(obj1->value, obj2->value); } + +const ObjectClass ListItem_class = { + .display = ListItem_display, + .delete = ListItem_delete, + .compare = ListItem_compare +}; |