ObjFW  Diff

Differences From Artifact [df231ae667]:

To Artifact [5a4773192e]:

  • File src/OFObject.h — part of check-in [28170f5f65] at 2012-03-15 11:29:24 on branch trunk — Greatly improve OFObject's memory handling and performance.

    A linked-list is put before each memory chunk allocated instead of
    having an array of all memory chunks. This means only one malloc now
    instead of one malloc and one realloc. This also means that when
    checking reallocs and frees, it's no longer necessary to iterate through
    all memory chunks, as the linked list also contains the owner, meaning
    realloc and free are no longer O(n), but O(1) now.

    As allocating bigger chunks seems to be a little bit slower than smaller
    chunks, it seems that this is slightly slower in benchmarks if only very small
    chunks are allocated. However, measuring real world usage, it's a lot faster. (user: js, size: 15956) [annotate] [blame] [check-ins using]


472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
 *
 * This is mostly for debugging purposes.
 *
 * \return A description for the object
 */
- (OFString*)description;

/**
 * \brief Adds a pointer to the object's memory pool.
 *
 * This is useful to add memory allocated by functions such as asprintf to the
 * pool so it gets free'd automatically when the object is deallocated.
 *
 * \param pointer A pointer to add to the memory pool
 */
- (void)addMemoryToPool: (void*)pointer;

/**
 * \brief Allocates memory and stores it in the object's memory pool.
 *
 * It will be free'd automatically when the object is deallocated.
 *
 * \param size The size of the memory to allocate
 * \return A pointer to the allocated memory







<
<
<
<
<
<
<
<
<
<







472
473
474
475
476
477
478










479
480
481
482
483
484
485
 *
 * This is mostly for debugging purposes.
 *
 * \return A description for the object
 */
- (OFString*)description;











/**
 * \brief Allocates memory and stores it in the object's memory pool.
 *
 * It will be free'd automatically when the object is deallocated.
 *
 * \param size The size of the memory to allocate
 * \return A pointer to the allocated memory