do_close_cleanup (void *arg)
{
int *fd = arg;
+
close (*fd);
}
make_cleanup_close (int fd)
{
int *saved_fd = xmalloc (sizeof (fd));
+
*saved_fd = fd;
return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
}
do_fclose_cleanup (void *arg)
{
FILE *file = arg;
+
fclose (file);
}
do_obstack_free (void *arg)
{
struct obstack *ob = arg;
+
obstack_free (ob, NULL);
}
restore_integer (void *p)
{
struct restore_integer_closure *closure = p;
+
*(closure->variable) = closure->value;
}
{
struct restore_integer_closure *c =
xmalloc (sizeof (struct restore_integer_closure));
+
c->variable = variable;
c->value = *variable;
struct cleanup *old_chain)
{
struct cleanup *ptr;
+
while ((ptr = *pmy_chain) != old_chain)
{
*pmy_chain = ptr->next; /* Do this first incase recursion */
struct cleanup *old_chain)
{
struct cleanup *ptr;
+
while ((ptr = *pmy_chain) != old_chain)
{
*pmy_chain = ptr->next;
free_current_contents (void *ptr)
{
void **location = ptr;
+
if (location == NULL)
internal_error (__FILE__, __LINE__,
_("free_current_contents: NULL pointer"));
discard_all_inferior_continuations (struct inferior *inf)
{
struct cleanup *continuation_ptr = &inf->continuations->base;
+
discard_my_cleanups (&continuation_ptr, NULL);
inf->continuations = NULL;
}
restore_thread_cleanup (void *arg)
{
ptid_t *ptid_p = arg;
+
switch_to_thread (*ptid_p);
}
void *data)
{
struct cleanup *continuation_ptr = &thread->continuations->base;
+
discard_my_cleanups (&continuation_ptr, NULL);
thread->continuations = NULL;
return 0;
void *data)
{
struct cleanup *continuation_ptr = &thread->intermediate_continuations->base;
+
discard_my_cleanups (&continuation_ptr, NULL);
thread->intermediate_continuations = NULL;
return 0;
warning (const char *string, ...)
{
va_list args;
+
va_start (args, string);
vwarning (string, args);
va_end (args);
error (const char *string, ...)
{
va_list args;
+
va_start (args, string);
throw_verror (GENERIC_ERROR, string, args);
va_end (args);
fatal (const char *string, ...)
{
va_list args;
+
va_start (args, string);
throw_vfatal (string, args);
va_end (args);
error_stream (struct ui_file *stream)
{
char *message = ui_file_xstrdup (stream, NULL);
+
make_cleanup (xfree, message);
error (("%s"), message);
}
internal_error (const char *file, int line, const char *string, ...)
{
va_list ap;
+
va_start (ap, string);
internal_verror (file, line, string, ap);
va_end (ap);
internal_warning (const char *file, int line, const char *string, ...)
{
va_list ap;
+
va_start (ap, string);
internal_vwarning (file, line, string, ap);
va_end (ap);
{
char *ret;
va_list args;
+
va_start (args, format);
ret = xstrvprintf (format, args);
va_end (args);
xasprintf (char **ret, const char *format, ...)
{
va_list args;
+
va_start (args, format);
(*ret) = xstrvprintf (format, args);
va_end (args);
{
char *ret = NULL;
int status = vasprintf (&ret, format, ap);
+
/* NULL is returned when there was a memory allocation problem, or
any other error (for instance, a bad format string). A negative
status (the printed length) with a non-NULL buffer should never
savestring (const char *ptr, size_t size)
{
char *p = (char *) xmalloc (size + 1);
+
memcpy (p, ptr, size);
p[size] = 0;
return p;
{
int target_char = -2; /* initialize to avoid GCC warnings */
int c = *(*string_ptr)++;
+
switch (c)
{
case '\n':
struct ui_file *stream)
{
int i;
+
for (i = 0; i < n; i++)
printchar (str[i], fputs_filtered, fprintf_filtered, stream, quoter);
}
putchar_unfiltered (int c)
{
char buf = c;
+
ui_file_write (gdb_stdout, &buf, 1);
return c;
}
fputc_unfiltered (int c, struct ui_file *stream)
{
char buf = c;
+
ui_file_write (stream, &buf, 1);
return c;
}
fprintf_filtered (struct ui_file *stream, const char *format, ...)
{
va_list args;
+
va_start (args, format);
vfprintf_filtered (stream, format, args);
va_end (args);
fprintf_unfiltered (struct ui_file *stream, const char *format, ...)
{
va_list args;
+
va_start (args, format);
vfprintf_unfiltered (stream, format, args);
va_end (args);
...)
{
va_list args;
+
va_start (args, format);
print_spaces_filtered (spaces, stream);
printf_filtered (const char *format, ...)
{
va_list args;
+
va_start (args, format);
vfprintf_filtered (gdb_stdout, format, args);
va_end (args);
printf_unfiltered (const char *format, ...)
{
va_list args;
+
va_start (args, format);
vfprintf_unfiltered (gdb_stdout, format, args);
va_end (args);
printfi_filtered (int spaces, const char *format, ...)
{
va_list args;
+
va_start (args, format);
print_spaces_filtered (spaces, gdb_stdout);
vfprintf_filtered (gdb_stdout, format, args);
subset_compare (char *string_to_compare, char *template_string)
{
int match;
+
if (template_string != (char *) NULL && string_to_compare != (char *) NULL
&& strlen (string_to_compare) <= strlen (template_string))
match =
{
static char buf[NUMCELLS][CELLSIZE];
static int cell = 0;
+
if (++cell >= NUMCELLS)
cell = 0;
return buf[cell];
hex_string (LONGEST num)
{
char *result = get_cell ();
+
xsnprintf (result, CELLSIZE, "0x%s", phex_nz (num, sizeof (num)));
return result;
}
core_addr_to_string (const CORE_ADDR addr)
{
char *str = get_cell ();
+
strcpy (str, "0x");
strcat (str, phex (addr, sizeof (addr)));
return str;
core_addr_to_string_nz (const CORE_ADDR addr)
{
char *str = get_cell ();
+
strcpy (str, "0x");
strcat (str, phex_nz (addr, sizeof (addr)));
return str;
{
unsigned int total = size * count;
void *ptr = obstack_alloc ((struct obstack *) data, total);
+
memset (ptr, 0, total);
return ptr;
}
gdb_buildargv (const char *s)
{
char **argv = buildargv (s);
+
if (s != NULL && argv == NULL)
nomem (0);
return argv;