From 6ad6e01e9b961fd5b25cc4d69319a7d29f110684 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Thu, 12 Jun 2014 00:04:32 +0000 Subject: Introduce helpers.c Move some suitable functions there, add it to the Makefile, but leave the declarations in flash.h for now. Corresponding to flashrom svn r1819. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- flashrom.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'flashrom.c') diff --git a/flashrom.c b/flashrom.c index a8a8533d..c9e0d016 100644 --- a/flashrom.c +++ b/flashrom.c @@ -535,42 +535,6 @@ int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, return 0; } -int min(int a, int b) -{ - return (a < b) ? a : b; -} - -int max(int a, int b) -{ - return (a > b) ? a : b; -} - -int bitcount(unsigned long a) -{ - int i = 0; - for (; a != 0; a >>= 1) - if (a & 1) - i++; - return i; -} - -void tolower_string(char *str) -{ - for (; *str != '\0'; str++) - *str = (char)tolower((unsigned char)*str); -} - -char *strcat_realloc(char *dest, const char *src) -{ - dest = realloc(dest, strlen(dest) + strlen(src) + 1); - if (!dest) { - msg_gerr("Out of memory!\n"); - return NULL; - } - strcat(dest, src); - return dest; -} - /* This is a somewhat hacked function similar in some ways to strtok(). * It will look for needle with a subsequent '=' in haystack, return a copy of * needle and remove everything from the first occurrence of needle to the next -- cgit v1.2.3