ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.223 by root, Sun Apr 6 14:34:50 2008 UTC vs.
Revision 1.224 by root, Wed Apr 9 22:07:50 2008 UTC

360 perror (msg); 360 perror (msg);
361 abort (); 361 abort ();
362 } 362 }
363} 363}
364 364
365static void *
366ev_realloc_emul (void *ptr, long size)
367{
368 /* some systems, notably openbsd and darwin, fail to properly
369 * implement realloc (x, 0) (as required by both ansi c-98 and
370 * the single unix specification, so work around them here.
371 */
372
373 if (size)
374 return realloc (ptr, size);
375
376 free (ptr);
377 return 0;
378}
379
365static void *(*alloc)(void *ptr, long size); 380static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
366 381
367void 382void
368ev_set_allocator (void *(*cb)(void *ptr, long size)) 383ev_set_allocator (void *(*cb)(void *ptr, long size))
369{ 384{
370 alloc = cb; 385 alloc = cb;
371} 386}
372 387
373inline_speed void * 388inline_speed void *
374ev_realloc (void *ptr, long size) 389ev_realloc (void *ptr, long size)
375{ 390{
376 ptr = alloc ? alloc (ptr, size) : realloc (ptr, size); 391 ptr = alloc (ptr, size);
377 392
378 if (!ptr && size) 393 if (!ptr && size)
379 { 394 {
380 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); 395 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size);
381 abort (); 396 abort ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines