Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/util.h

    r791f58c r38b3baf  
    4141extern char *get_path_elem_end(char *);
    4242
    43 extern bool skip_spaces(char **);
    44 extern size_t get_nonspace_len(const char *);
    45 extern void free_not_null(const void *);
    46 extern char *clone_string(const char *);
    47 extern void replace_char(char *, char, char);
     43static inline bool skip_spaces(char **buf)
     44{
     45        while (isspace(**buf))
     46                (*buf)++;
     47        return *buf != 0;
     48}
     49
     50static inline size_t get_nonspace_len(const char *str)
     51{
     52        size_t len = 0;
     53       
     54        while(*str != 0 && !isspace(*str)) {
     55                len++;
     56                str++;
     57        }
     58        return len;
     59}
     60
     61static inline void free_not_null(const void *ptr)
     62{
     63        if (NULL != ptr)
     64                free(ptr);
     65}
     66
     67static inline char *clone_string(const char *s)
     68{
     69        size_t size = str_size(s) + 1;
     70        char *str;
     71       
     72        str = (char *) malloc(size);
     73        if (NULL != str)
     74                str_cpy(str, size, s);
     75        return str;
     76}
     77
     78static inline void replace_char(char *str, char orig, char repl)
     79{
     80        while (*str) {
     81                if (orig == *str)
     82                        *str = repl;
     83                str++;
     84        }
     85}
    4886
    4987#endif
Note: See TracChangeset for help on using the changeset viewer.