The R Project SVN R

Rev

Rev 83460 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83460 Rev 83463
Line 20... Line 20...
20
//#include <assert.h>
20
//#include <assert.h>
21
#include <stdio.h>
21
#include <stdio.h>
22
#define XMALLOC_INTERNAL 1
22
#define XMALLOC_INTERNAL 1
23
#include "xmalloc.h"
23
#include "xmalloc.h"
24
 
24
 
25
#include <stdint.h> /* for uintptr_t */
-
 
26
 
-
 
27
/* fake definition */
25
/* fake definition */
28
extern void Rf_error(const char *str, ...);
26
extern void Rf_error(const char *str, ...);
29
#define assert(a) R_assert(a)
27
#define assert(a) R_assert(a)
30
 
28
 
31
static void assert(int expr)
29
static void assert(int expr)
Line 352... Line 350...
352
      assert(0);
350
      assert(0);
353
    }
351
    }
354
  else if (xmalloc_fail_after > 0)
352
  else if (xmalloc_fail_after > 0)
355
    xmalloc_fail_after--;
353
    xmalloc_fail_after--;
356
 
354
 
357
  uintptr_t old_address = (uintptr_t) ptr; /* -Wuse-after-free */
-
 
358
  new_ptr = realloc(ptr, new_size);
355
  new_ptr = realloc(ptr, new_size);
359
  if (new_ptr != NULL)
356
  if (new_ptr != NULL)
360
    {
357
    {
361
      hash_table_del(xmalloc_table, (void *)old_address);
358
      hash_table_del(xmalloc_table, ptr); /* -Wuse-after-free is false alarm */
362
      hash_table_add(xmalloc_table, new_ptr, (int)new_size, file, line, func);
359
      hash_table_add(xmalloc_table, new_ptr, (int)new_size, file, line, func);
363
    }
360
    }
364
  return new_ptr;
361
  return new_ptr;
365
}
362
}
366
 
363