Commits

Ruslan Osmanov committed d0f3875

EvStat done

Comments (0)

Files changed (3)

 
 typedef struct php_ev_stat {
 	struct ev_stat  stat;   /* Contains common watcher vars embedded */
-	char *path;
+	char           *path;
 } php_ev_stat;
 
 #endif /* PHP_EV_EMBED_H */
 		ev_periodic_set(periodic_watcher, offset, interval, 0);
 	}
 
-	o_self->ptr     = (void *) periodic_ptr;
+	o_self->ptr = (void *) periodic_ptr;
 }
 /* }}} */
 
 	PHP_EV_CHECK_REPEAT(interval);
 
 	ev_obj           = (php_ev_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
-	periodic_watcher = (ev_periodic *) PHP_EV_WATCHER_FETCH_FROM_OBJECT(ev_obj);
 	periodic_ptr     = (php_ev_periodic *) PHP_EV_WATCHER_FETCH_FROM_OBJECT(ev_obj);
+	periodic_watcher = (ev_periodic *) periodic_ptr;
 	
 	/* Free fci and fcc within periodic_ptr, since they will be overwritten anyways */
 
 	stat_ptr = (php_ev_stat *) emalloc(sizeof(php_ev_stat));
 	memset(stat_ptr, 0, sizeof(php_ev_stat));
 	
-	stat_ptr->path = estrdup(path); 
+	stat_ptr->path = estrndup(path, path_len); 
 
 	stat_watcher = &stat_ptr->stat;
 
 	self         = getThis();
 	o_self       = (php_ev_object *) zend_object_store_get_object(self TSRMLS_CC);
 	o_loop       = (php_ev_object *) zend_object_store_get_object(loop TSRMLS_CC);
-	stat_watcher = (ev_stat *) php_ev_new_watcher(sizeof(ev_stat), self,
+
+	php_ev_set_watcher((ev_watcher *)stat_watcher, sizeof(ev_stat), self,
 			PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(o_loop),
 			&fci, &fcc, data, priority TSRMLS_CC);
 
-
 	stat_watcher->type = EV_STAT;
 	
 	ev_stat_set(stat_watcher, stat_ptr->path, interval);
 }
 /* }}} */
 
-/* {{{ proto void EvStat::set(double after, double repeat) */
+/* {{{ proto void EvStat::set(string path, double interval) */
 PHP_METHOD(EvStat, set)
 {
-	char    *path;
-	int      path_len;
-	double   interval;
-	ev_stat *stat_watcher;
+	char          *path;
+	int            path_len;
+	double         interval;
+	ev_stat       *stat_watcher;
+	php_ev_stat   *stat_ptr;
+	php_ev_object *ev_obj;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pd",
 				&path, &path_len, &interval) == FAILURE) {
 
 	stat_watcher = (ev_stat *) PHP_EV_WATCHER_FETCH_FROM_THIS();
 
-	PHP_EV_WATCHER_RESET(ev_stat, stat_watcher, (stat_watcher, path, interval));
+	ev_obj       = (php_ev_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+	stat_ptr     = (php_ev_stat *) PHP_EV_WATCHER_FETCH_FROM_OBJECT(ev_obj);
+	stat_watcher = (ev_stat *) stat_ptr;
+
+	PHP_EV_ASSERT(stat_ptr->path);
+	efree(stat_ptr->path);
+	stat_ptr->path = estrndup(path, path_len);
+
+	PHP_EV_WATCHER_RESET(ev_stat, stat_watcher, (stat_watcher, stat_ptr->path, interval));
 }
 /* }}} */
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.