@@ -540,9 +540,7 @@ int database_exec_callback (cloudsync_context *data, const char *sql, int (*call
540540
541541 // Allocate arrays for column names and values
542542 char * * names = cloudsync_memory_alloc (ncols * sizeof (char * ));
543- if (!names ) return DBRES_NOMEM ;
544543 char * * values = cloudsync_memory_alloc (ncols * sizeof (char * ));
545- if (!values ) {cloudsync_memory_free (names ); return DBRES_NOMEM ;}
546544
547545 // Get column names
548546 for (int i = 0 ; i < ncols ; i ++ ) {
@@ -951,7 +949,8 @@ int database_pk_names (cloudsync_context *data, const char *table_name, char ***
951949 Datum datum = SPI_getbinval (tuple , SPI_tuptable -> tupdesc , 1 , & isnull );
952950 if (!isnull ) {
953951 text * txt = DatumGetTextP (datum );
954- pk_names [i ] = text_to_cstring (txt );
952+ char * name = text_to_cstring (txt );
953+ pk_names [i ] = cloudsync_string_dup (name );
955954 } else {
956955 pk_names [i ] = NULL ;
957956 }
@@ -1711,19 +1710,19 @@ int database_rollback_savepoint (cloudsync_context *data, const char *savepoint_
17111710// MARK: - MEMORY -
17121711
17131712void * dbmem_alloc (uint64_t size ) {
1714- return palloc (size );
1713+ return malloc (size );
17151714}
17161715
17171716void * dbmem_zeroalloc (uint64_t size ) {
1718- void * ptr = palloc (size );
1717+ void * ptr = malloc (size );
17191718 if (ptr ) {
17201719 memset (ptr , 0 , (size_t )size );
17211720 }
17221721 return ptr ;
17231722}
17241723
17251724void * dbmem_realloc (void * ptr , uint64_t new_size ) {
1726- return repalloc (ptr , new_size );
1725+ return realloc (ptr , new_size );
17271726}
17281727
17291728char * dbmem_mprintf (const char * format , ...) {
@@ -1744,7 +1743,7 @@ char *dbmem_mprintf(const char *format, ...) {
17441743 }
17451744
17461745 // Allocate buffer and format string
1747- char * result = (char * )palloc (len + 1 );
1746+ char * result = (char * )malloc (len + 1 );
17481747 vsnprintf (result , len + 1 , format , args );
17491748
17501749 va_end (args );
@@ -1763,14 +1762,16 @@ char *dbmem_vmprintf (const char *format, va_list list) {
17631762 if (len < 0 ) return NULL ;
17641763
17651764 // Allocate buffer and format string
1766- char * result = (char * )palloc (len + 1 );
1765+ char * result = (char * )malloc (len + 1 );
17671766 vsnprintf (result , len + 1 , format , list );
17681767
17691768 return result ;
17701769}
17711770
17721771void dbmem_free (void * ptr ) {
1773- if (ptr ) pfree (ptr );
1772+ if (ptr ) {
1773+ free (ptr );
1774+ }
17741775}
17751776
17761777uint64_t dbmem_size (void * ptr ) {
0 commit comments