mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
fd: fix table cloning
This commit is contained in:
+7
-1
@@ -114,12 +114,18 @@ int fd_tableclone(fdtable_t* source, fdtable_t* dest){
|
|||||||
|
|
||||||
spinlock_acquire(&source->lock);
|
spinlock_acquire(&source->lock);
|
||||||
|
|
||||||
|
if(fd_tableinit(dest)){
|
||||||
|
spinlock_release(&source->lock);
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
if(source->fdcount != dest->fdcount){
|
if(source->fdcount != dest->fdcount){
|
||||||
void* tmp = alloc(source->fdcount*sizeof(fd_t*));
|
void* tmp = realloc(dest->fd, source->fdcount*sizeof(fd_t*));
|
||||||
if(!tmp){
|
if(!tmp){
|
||||||
spinlock_release(&source->lock);
|
spinlock_release(&source->lock);
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
dest->fd = tmp;
|
||||||
dest->fdcount = source->fdcount;
|
dest->fdcount = source->fdcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user