Merge pull request #811 from namhyung/busctl-misc-v2

busctl: Misc cleanups and a fix (v2)
This commit is contained in:
Daniel Mack
2015-07-31 19:40:57 +02:00
4 changed files with 33 additions and 25 deletions
+13 -7
View File
@@ -115,17 +115,23 @@ size_t page_size(void) {
return pgsz;
}
bool streq_ptr(const char *a, const char *b) {
/* Like streq(), but tries to make sense of NULL pointers */
int strcmp_ptr(const char *a, const char *b) {
/* Like strcmp(), but tries to make sense of NULL pointers */
if (a && b)
return streq(a, b);
return strcmp(a, b);
if (!a && !b)
return true;
if (!a && b)
return -1;
return false;
if (a && !b)
return 1;
return 0;
}
bool streq_ptr(const char *a, const char *b) {
return strcmp_ptr(a, b) == 0;
}
char* endswith(const char *s, const char *postfix) {
+1
View File
@@ -71,6 +71,7 @@ size_t page_size(void) _pure_;
#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
bool streq_ptr(const char *a, const char *b) _pure_;
int strcmp_ptr(const char *a, const char *b) _pure_;
#define new(t, n) ((t*) malloc_multiply(sizeof(t), (n)))