/[path-sandbox]/trunk/src/sandbox_utils.c
Gentoo

Diff of /trunk/src/sandbox_utils.c

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

trunk/src/sandbox_futils.c Revision 209 trunk/src/sandbox_utils.c Revision 216
1/* 1/*
2 * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com> 2 * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com>
3 * Distributed under the terms of the GNU General Public License, v2 or later 3 * Distributed under the terms of the GNU General Public License, v2 or later
4 * Author: Brad House <brad@mainstreetsoftworks.com> 4 * Author: Brad House <brad@mainstreetsoftworks.com>
5 * Author: Martin Schlemmer <azarah@gentoo.org>
5 * 6 *
6 * $Header$ 7 * $Header$
7 * 8 *
8 */ 9 */
9 10
163 return (st.st_size); 164 return (st.st_size);
164} 165}
165 166
166#endif /* OUTSIDE_LIBSANDBOX */ 167#endif /* OUTSIDE_LIBSANDBOX */
167 168
169char * gstrndup (const char *str, size_t size)
170{
171 char *new_str = NULL;
172 size_t len;
173
174 if (NULL == str)
175 return NULL;
176
177 /* Check lenght of str without breaching the size limit */
178 for (len = 0; (len < size) && ('\0' != str[len]); len++);
179
180 new_str = malloc (len + 1);
181 if (NULL == new_str)
182 return NULL;
183
184 /* Make sure our string is NULL terminated */
185 new_str[len] = '\0';
186
187 return (char *) memcpy (new_str, str, len);
188}
189
190char *
191gbasename (const char *path)
192{
193 char *new_path = NULL;
194
195 if (NULL == path)
196 return NULL;
197
198 /* Copied from glibc */
199 new_path = strrchr (path, '/');
200 return new_path ? new_path + 1 : (char *) path;
201}
202
168 203
169// vim:noexpandtab noai:cindent ai 204// vim:noexpandtab noai:cindent ai

Legend:
Removed from v.209  
changed lines
  Added in v.216

  ViewVC Help
Powered by ViewVC 1.1.20