Skip to content

Commit 00b3c4c

Browse files
committed
Fix issue with MAKE_STD_ZVAL
1 parent ee1cb00 commit 00b3c4c

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

win32ps.c

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PHP_MINFO_FUNCTION(win32ps)
6666
PHP_WIN32PS_API int php_win32ps_procinfo(int proc, zval *array, int error_flags TSRMLS_DC)
6767
{
6868
char f[MAX_PATH + 1] = {0};
69-
zval *mem, *tms;
69+
zval mem, tms;
7070
int l;
7171
HANDLE h;
7272
SYSTEMTIME nows;
@@ -137,29 +137,31 @@ PHP_WIN32PS_API int php_win32ps_procinfo(int proc, zval *array, int error_flags
137137
add_assoc_stringl(array, "exe", f, l, 1);
138138
}
139139

140-
array_init(mem);
141-
add_assoc_zval(array, "mem", mem);
140+
//MAKE_STD_ZVAL(mem);
141+
array_init(&mem);
142+
add_assoc_zval(array, "mem", &mem);
142143
/* Number of page faults. */
143-
add_assoc_long(mem, "page_fault_count", (long) memory.PageFaultCount);
144+
add_assoc_long(&mem, "page_fault_count", (long) memory.PageFaultCount);
144145
/* Peak working set size, in bytes. */
145-
add_assoc_long(mem, "peak_working_set_size", (long) memory.PeakWorkingSetSize);
146+
add_assoc_long(&mem, "peak_working_set_size", (long) memory.PeakWorkingSetSize);
146147
/* Current working set size, in bytes. */
147-
add_assoc_long(mem, "working_set_size", (long) memory.WorkingSetSize);
148+
add_assoc_long(&mem, "working_set_size", (long) memory.WorkingSetSize);
148149
/* Peak paged pool usage, in bytes. */
149-
add_assoc_long(mem, "quota_peak_paged_pool_usage", (long) memory.QuotaPeakPagedPoolUsage);
150+
add_assoc_long(&mem, "quota_peak_paged_pool_usage", (long) memory.QuotaPeakPagedPoolUsage);
150151
/* Current paged pool usage, in bytes. */
151-
add_assoc_long(mem, "quota_paged_pool_usage", (long) memory.QuotaPagedPoolUsage);
152+
add_assoc_long(&mem, "quota_paged_pool_usage", (long) memory.QuotaPagedPoolUsage);
152153
/* Peak nonpaged pool usage, in bytes. */
153-
add_assoc_long(mem, "quota_peak_non_paged_pool_usage", (long) memory.QuotaPeakNonPagedPoolUsage);
154+
add_assoc_long(&mem, "quota_peak_non_paged_pool_usage", (long) memory.QuotaPeakNonPagedPoolUsage);
154155
/* Current nonpaged pool usage, in bytes. */
155-
add_assoc_long(mem, "quota_non_paged_pool_usage", (long) memory.QuotaNonPagedPoolUsage);
156+
add_assoc_long(&mem, "quota_non_paged_pool_usage", (long) memory.QuotaNonPagedPoolUsage);
156157
/* Current space allocated for the pagefile, in bytes. Those pages may or may not be in memory. */
157-
add_assoc_long(mem, "pagefile_usage", (long) memory.PagefileUsage);
158+
add_assoc_long(&mem, "pagefile_usage", (long) memory.PagefileUsage);
158159
/* Peak space allocated for the pagefile, in bytes. */
159-
add_assoc_long(mem, "peak_pagefile_usage", (long) memory.PeakPagefileUsage);
160-
161-
array_init(tms);
162-
add_assoc_zval(array, "tms", tms);
160+
add_assoc_long(&mem, "peak_pagefile_usage", (long) memory.PeakPagefileUsage);
161+
162+
//MAKE_STD_ZVAL(tms);
163+
array_init(&tms);
164+
add_assoc_zval(array, "tms", &tms);
163165

164166
/* Current time, 100's of nsec */
165167
GetSystemTime(&nows);
@@ -168,13 +170,13 @@ PHP_WIN32PS_API int php_win32ps_procinfo(int proc, zval *array, int error_flags
168170

169171
/* Creation time, in seconds with msec precision */
170172
memcpy(&creatx, &creat, sizeof(unsigned __int64));
171-
add_assoc_double(tms, "created", (double) ((__int64) ((nowx-creatx) / 10000Ui64)) / 1000.0);
173+
add_assoc_double(&tms, "created", (double) ((__int64) ((nowx-creatx) / 10000Ui64)) / 1000.0);
172174
/* Kernel time, in seconds with msec precision */
173175
memcpy(&kernx, &kern, sizeof(unsigned __int64));
174-
add_assoc_double(tms, "kernel", (double) ((__int64) (kernx / 10000Ui64)) / 1000.0);
176+
add_assoc_double(&tms, "kernel", (double) ((__int64) (kernx / 10000Ui64)) / 1000.0);
175177
/* User time, in seconds with msec precision */
176178
memcpy(&userx, &user, sizeof(unsigned __int64));
177-
add_assoc_double(tms, "user", (double) ((__int64) (userx / 10000Ui64)) / 1000.0);
179+
add_assoc_double(&tms, "user", (double) ((__int64) (userx / 10000Ui64)) / 1000.0);
178180

179181
return SUCCESS;
180182
}
@@ -223,11 +225,11 @@ PHP_FUNCTION(win32_ps_list_procs)
223225

224226
array_init(return_value);
225227
for (i = 0; i < proc_count/sizeof(int); ++i) {
226-
zval *entry;
228+
zval entry;
227229

228-
array_init(entry);
229-
if (SUCCESS == php_win32ps_procinfo(processes[i], entry, PHP_WIN32PS_HANDLE_OPS TSRMLS_CC)) {
230-
add_next_index_zval(return_value, entry);
230+
array_init(&entry);
231+
if (SUCCESS == php_win32ps_procinfo(processes[i], &entry, PHP_WIN32PS_HANDLE_OPS TSRMLS_CC)) {
232+
add_next_index_zval(return_value, &entry);
231233
} else {
232234
zval_ptr_dtor(&entry);
233235
}

0 commit comments

Comments
 (0)