refactoring more of goodies.h into strings.h

This commit is contained in:
Enno Rehling 2015-05-18 08:59:38 +02:00
parent 820cdccf32
commit 8e5fc28bfc
13 changed files with 36 additions and 42 deletions

View File

@ -42,7 +42,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/bsdstring.h> #include <util/bsdstring.h>
#include <util/goodies.h> #include <util/strings.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/log.h> #include <util/log.h>
#include <util/resolve.h> #include <util/resolve.h>

View File

@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* util includes */ /* util includes */
#include <critbit.h> #include <critbit.h>
#include <util/goodies.h> #include <util/strings.h>
#include <util/language.h> #include <util/language.h>
#include <util/log.h> #include <util/log.h>
#include <util/umlaut.h> #include <util/umlaut.h>

View File

@ -48,7 +48,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/base36.h> #include <util/base36.h>
#include <util/bsdstring.h> #include <util/bsdstring.h>
#include <util/event.h> #include <util/event.h>
#include <util/goodies.h> #include <util/strings.h>
#include <util/language.h> #include <util/language.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/log.h> #include <util/log.h>

View File

@ -49,7 +49,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/base36.h> #include <util/base36.h>
#include <util/event.h> #include <util/event.h>
#include <util/functions.h> #include <util/functions.h>
#include <util/goodies.h> #include <util/strings.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/log.h> #include <util/log.h>
#include <util/resolve.h> #include <util/resolve.h>

View File

@ -43,7 +43,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/functions.h> #include <util/functions.h>
#include <util/goodies.h> #include <util/strings.h>
#include <util/language.h> #include <util/language.h>
#include <storage.h> #include <storage.h>

View File

@ -15,7 +15,7 @@
#include "crmessage.h" #include "crmessage.h"
#include "message.h" #include "message.h"
#include "goodies.h" #include "strings.h"
#include "log.h" #include "log.h"
#include <stdio.h> #include <stdio.h>

View File

@ -19,12 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include "goodies.h" #include "goodies.h"
#include "unicode.h"
/* libc includes */ /* libc includes */
#include <wctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
/* Simple Integer-Liste */ /* Simple Integer-Liste */
@ -53,23 +49,6 @@ int *intlist_find(int *i_p, int fi)
return NULL; return NULL;
} }
char *set_string(char **s, const char *neu)
{
if (neu == NULL) {
free(*s);
*s = NULL;
}
else if (*s == NULL) {
*s = malloc(strlen(neu) + 1);
strcpy(*s, neu);
}
else {
*s = realloc(*s, strlen(neu) + 1);
strcpy(*s, neu);
}
return *s;
}
static int spc_email_isvalid(const char *address) static int spc_email_isvalid(const char *address)
{ {
int count = 0; int count = 0;

View File

@ -19,18 +19,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GOODIES_H #ifndef GOODIES_H
#define GOODIES_H #define GOODIES_H
#include "strings.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern char *set_string(char **s, const char *neu); int set_email(char **pemail, const char *newmail);
extern int set_email(char **pemail, const char *newmail);
extern int *intlist_init(void); int *intlist_init(void);
extern int *intlist_add(int *i_p, int i); int *intlist_add(int *i_p, int i);
extern int *intlist_find(int *i_p, int i); int *intlist_find(int *i_p, int i);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "language_struct.h" #include "language_struct.h"
#include "log.h" #include "log.h"
#include "goodies.h" #include "strings.h"
#include "umlaut.h" #include "umlaut.h"
#include <stdlib.h> #include <stdlib.h>

View File

@ -14,7 +14,7 @@
#include <platform.h> #include <platform.h>
#include "message.h" #include "message.h"
#include "goodies.h" #include "strings.h"
#include "log.h" #include "log.h"
#include "quicklist.h" #include "quicklist.h"

View File

@ -21,7 +21,7 @@
#include "message.h" #include "message.h"
#include "language.h" #include "language.h"
#include "translation.h" #include "translation.h"
#include "goodies.h" #include "strings.h"
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>

View File

@ -21,6 +21,24 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* libc includes */ /* libc includes */
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
char *set_string(char **s, const char *neu)
{
if (neu == NULL) {
free(*s);
*s = NULL;
}
else if (*s == NULL) {
*s = malloc(strlen(neu) + 1);
strcpy(*s, neu);
}
else {
*s = realloc(*s, strlen(neu) + 1);
strcpy(*s, neu);
}
return *s;
}
unsigned int hashstring(const char *s) unsigned int hashstring(const char *s)
{ {

View File

@ -22,11 +22,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
extern unsigned int hashstring(const char *s); char *set_string(char **s, const char *neu);
extern const char *escape_string(const char *str, char *buffer, unsigned int hashstring(const char *s);
size_t len); const char *escape_string(const char *str, char *buffer, size_t len);
extern unsigned int jenkins_hash(unsigned int a); unsigned int jenkins_hash(unsigned int a);
extern unsigned int wang_hash(unsigned int a); unsigned int wang_hash(unsigned int a);
/* benchmark for units: /* benchmark for units:
* JENKINS_HASH: 5.25 misses/hit (with good cache behavior) * JENKINS_HASH: 5.25 misses/hit (with good cache behavior)