@@ -83,8 +83,7 @@ STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg);
8383
8484STATIC mp_obj_t uhashlib_sha256_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
8585 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
86- mp_obj_hash_t * o = m_new_obj_var (mp_obj_hash_t , char , sizeof (mbedtls_sha256_context ));
87- o -> base .type = type ;
86+ mp_obj_hash_t * o = mp_obj_malloc_var (mp_obj_hash_t , char , sizeof (mbedtls_sha256_context ), type );
8887 o -> final = false;
8988 mbedtls_sha256_init ((mbedtls_sha256_context * )& o -> state );
9089 mbedtls_sha256_starts_ret ((mbedtls_sha256_context * )& o -> state , 0 );
@@ -119,8 +118,7 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
119118
120119STATIC mp_obj_t uhashlib_sha256_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
121120 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
122- mp_obj_hash_t * o = m_new_obj_var (mp_obj_hash_t , char , sizeof (CRYAL_SHA256_CTX ));
123- o -> base .type = type ;
121+ mp_obj_hash_t * o = mp_obj_malloc_var (mp_obj_hash_t , char , sizeof (CRYAL_SHA256_CTX ), type );
124122 o -> final = false;
125123 sha256_init ((CRYAL_SHA256_CTX * )o -> state );
126124 if (n_args == 1 ) {
@@ -173,8 +171,7 @@ STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
173171#if MICROPY_SSL_AXTLS
174172STATIC mp_obj_t uhashlib_sha1_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
175173 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
176- mp_obj_hash_t * o = m_new_obj_var (mp_obj_hash_t , char , sizeof (SHA1_CTX ));
177- o -> base .type = type ;
174+ mp_obj_hash_t * o = mp_obj_malloc_var (mp_obj_hash_t , char , sizeof (SHA1_CTX ), type );
178175 o -> final = false;
179176 SHA1_Init ((SHA1_CTX * )o -> state );
180177 if (n_args == 1 ) {
@@ -213,8 +210,7 @@ STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) {
213210
214211STATIC mp_obj_t uhashlib_sha1_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
215212 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
216- mp_obj_hash_t * o = m_new_obj_var (mp_obj_hash_t , char , sizeof (mbedtls_sha1_context ));
217- o -> base .type = type ;
213+ mp_obj_hash_t * o = mp_obj_malloc_var (mp_obj_hash_t , char , sizeof (mbedtls_sha1_context ), type );
218214 o -> final = false;
219215 mbedtls_sha1_init ((mbedtls_sha1_context * )o -> state );
220216 mbedtls_sha1_starts_ret ((mbedtls_sha1_context * )o -> state );
@@ -268,8 +264,7 @@ STATIC mp_obj_t uhashlib_md5_update(mp_obj_t self_in, mp_obj_t arg);
268264#if MICROPY_SSL_AXTLS
269265STATIC mp_obj_t uhashlib_md5_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
270266 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
271- mp_obj_hash_t * o = m_new_obj_var (mp_obj_hash_t , char , sizeof (MD5_CTX ));
272- o -> base .type = type ;
267+ mp_obj_hash_t * o = mp_obj_malloc_var (mp_obj_hash_t , char , sizeof (MD5_CTX ), type );
273268 o -> final = false;
274269 MD5_Init ((MD5_CTX * )o -> state );
275270 if (n_args == 1 ) {
@@ -308,8 +303,7 @@ STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) {
308303
309304STATIC mp_obj_t uhashlib_md5_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
310305 mp_arg_check_num (n_args , n_kw , 0 , 1 , false);
311- mp_obj_hash_t * o = m_new_obj_var (mp_obj_hash_t , char , sizeof (mbedtls_md5_context ));
312- o -> base .type = type ;
306+ mp_obj_hash_t * o = mp_obj_malloc_var (mp_obj_hash_t , char , sizeof (mbedtls_md5_context ), type );
313307 o -> final = false;
314308 mbedtls_md5_init ((mbedtls_md5_context * )o -> state );
315309 mbedtls_md5_starts_ret ((mbedtls_md5_context * )o -> state );
0 commit comments