@@ -85,33 +85,51 @@ impl Pool {
8585 }
8686
8787 /// Allocates memory from the pool of the specified size.
88+ /// The resulting pointer is aligned to a platform word size.
8889 ///
8990 /// Returns a raw pointer to the allocated memory.
9091 pub fn alloc ( & mut self , size : usize ) -> * mut c_void {
9192 unsafe { ngx_palloc ( self . 0 , size) }
9293 }
9394
9495 /// Allocates memory for a type from the pool.
96+ /// The resulting pointer is aligned to a platform word size.
9597 ///
9698 /// Returns a typed pointer to the allocated memory.
9799 pub fn alloc_type < T : Copy > ( & mut self ) -> * mut T {
98100 self . alloc ( mem:: size_of :: < T > ( ) ) as * mut T
99101 }
100102
101103 /// Allocates zeroed memory from the pool of the specified size.
104+ /// The resulting pointer is aligned to a platform word size.
102105 ///
103106 /// Returns a raw pointer to the allocated memory.
104107 pub fn calloc ( & mut self , size : usize ) -> * mut c_void {
105108 unsafe { ngx_pcalloc ( self . 0 , size) }
106109 }
107110
108111 /// Allocates zeroed memory for a type from the pool.
112+ /// The resulting pointer is aligned to a platform word size.
109113 ///
110114 /// Returns a typed pointer to the allocated memory.
111115 pub fn calloc_type < T : Copy > ( & mut self ) -> * mut T {
112116 self . calloc ( mem:: size_of :: < T > ( ) ) as * mut T
113117 }
114118
119+ /// Allocates unaligned memory from the pool of the specified size.
120+ ///
121+ /// Returns a raw pointer to the allocated memory.
122+ pub fn alloc_unaligned ( & mut self , size : usize ) -> * mut c_void {
123+ unsafe { ngx_pnalloc ( self . 0 , size) }
124+ }
125+
126+ /// Allocates unaligned memory for a type from the pool.
127+ ///
128+ /// Returns a typed pointer to the allocated memory.
129+ pub fn alloc_type_unaligned < T : Copy > ( & mut self ) -> * mut T {
130+ self . alloc_unaligned ( mem:: size_of :: < T > ( ) ) as * mut T
131+ }
132+
115133 /// Allocates memory for a value of a specified type and adds a cleanup handler to the memory pool.
116134 ///
117135 /// Returns a typed pointer to the allocated memory if successful, or a null pointer if allocation or cleanup handler addition fails.
0 commit comments