X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpool.h;h=a5d91dd7769ba61eade54552b0c63bdc0e4e20f9;hb=e210b20bf6f405637c8c03dd280b5a4a627191b8;hp=e884ae61e723a4d063deebdadc99ed9f9d5db817;hpb=4fdeb2145d081ff1b84e3f6c99f9d1c048c0d64a;p=pspp diff --git a/src/pool.h b/src/pool.h index e884ae61e7..a5d91dd776 100644 --- a/src/pool.h +++ b/src/pool.h @@ -38,20 +38,35 @@ struct pool *pool_create (void); void pool_destroy (struct pool *); void pool_clear (struct pool *); +/* Creates a pool, allocates an instance of the given STRUCT + within it, sets the struct's MEMBER to the pool's address, and + returns the allocated structure. */ +#define pool_create_container(STRUCT, MEMBER) \ + ((STRUCT *) pool_create_at_offset (sizeof (STRUCT), \ + offsetof (STRUCT, MEMBER))) +void *pool_create_at_offset (size_t struct_size, size_t pool_member_offset); + /* Suballocation routines. */ void *pool_alloc (struct pool *, size_t) MALLOC_LIKE; +void *pool_nalloc (struct pool *, size_t n, size_t s) MALLOC_LIKE; void *pool_clone (struct pool *, const void *, size_t) MALLOC_LIKE; + +void *pool_alloc_unaligned (struct pool *, size_t) MALLOC_LIKE; +void *pool_clone_unaligned (struct pool *, const void *, size_t) MALLOC_LIKE; char *pool_strdup (struct pool *, const char *) MALLOC_LIKE; -char *pool_strndup (struct pool *, const char *, size_t) MALLOC_LIKE; char *pool_strcat (struct pool *, const char *, ...) MALLOC_LIKE; /* Standard allocation routines. */ void *pool_malloc (struct pool *, size_t) MALLOC_LIKE; +void *pool_nmalloc (struct pool *, size_t n, size_t s) MALLOC_LIKE; void *pool_realloc (struct pool *, void *, size_t); +void *pool_nrealloc (struct pool *, void *, size_t n, size_t s); +void *pool_2nrealloc (struct pool *, void *, size_t *pn, size_t s); void pool_free (struct pool *, void *); /* Gizmo allocations. */ struct pool *pool_create_subpool (struct pool *); +void pool_add_subpool (struct pool *, struct pool *subpool); FILE *pool_fopen (struct pool *, const char *, const char *); int pool_fclose (struct pool *, FILE *);