English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/common-nfo/tools/sqlite/dbif.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3446 by tg, Wed Aug 8 14:55:33 2007 UTC revision 3447 by tg, Wed Aug 8 16:14:20 2007 UTC
# Line 92  __END_DECLS Line 92  __END_DECLS
92          (xmalloc_ptr);                                  \          (xmalloc_ptr);                                  \
93  })  })
94    
95    #define xrealloc(ptr, size) ({                          \
96            void *xrealloc_newptr;                          \
97            size_t xrealloc_sz = (size);                    \
98                                                            \
99            xrealloc_newptr = realloc((ptr), xrealloc_sz);  \
100            if (xrealloc_newptr == NULL)                    \
101                    err(255, "cannot realloc to %zu bytes", \
102                        xrealloc_sz);                       \
103            (xrealloc_newptr);                              \
104    })
105    
106    #define str_save(s) ({                                  \
107            const char *str_save_s = (s);                   \
108                                                            \
109            (str_nsave(str_save_s, strlen(str_save_s)));    \
110    })
111    
112    #define str_nsave(s, n) ({                              \
113            char *str_nsave_ptr;                            \
114            size_t str_nsave_sz = (n);                      \
115                                                            \
116            str_nsave_ptr = xmalloc(str_nsave_sz + 1);      \
117            memcpy(str_nsave_sz, (s), str_nsave_sz);        \
118            str_nsave_ptr[str_nsave_sz] = '\0';             \
119            (str_nsave_ptr);                                \
120    })
121    
122    #define str_add(d, s) ({                                \
123            const char *str_add_s = (s);                    \
124                                                            \
125            (str_nadd((d), str_add_s, strlen(str_add_s)));  \
126    })
127    
128    #define str_nadd(d, s, n) ({                            \
129            char *str_nadd_ptr = (d), *str_nadd_newptr;     \
130            size_t str_nadd_sz, str_nadd_addsz = (n);       \
131                                                            \
132            str_nadd_sz = strlen(str_nadd_ptr);             \
133            str_nadd_newptr = xrealloc(str_nadd_ptr,        \
134                str_nadd_sz + str_nadd_addsz + 1);          \
135            str_nadd_ptr = str_nadd_newptr + str_nadd_sz;   \
136            memcpy(str_nadd_ptr, (s), str_nadd_addsz);      \
137            str_nadd_ptr[str_nadd_addsz] = '\0';            \
138            (str_nadd_newptr);                              \
139    })
140    
141  #endif  #endif

Legend:
Removed from v.3446  
changed lines
  Added in v.3447

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20